Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Al Azif
Nov 1, 2006

shopvac4christ posted:

What's the 'proper' way to put it in a project of mine? I'd imagine stuffing it all in a 'lib/', pushing that directory onto my load path, and requiring them would work - but what if those projects update? Just replace the files in lib?

Yes, and yes.

Adbot
ADBOT LOVES YOU

Al Azif
Nov 1, 2006
I've been using Ruby for a while now, but this is my first foray into Rails (I'm a big fan of Camping, but past a certain size Camping apps get difficult to handle).

I want to be able to do this in a controller method:

code:
def index
  @orders = @user.orders
end
instead of this:

code:
def index
  @user = find_user
  @orders = @user.orders
end
Where find_user returns the user object for the current session. I think I want this for every action on every controller. Having to stick find_user in every controller method isn't very DRY, right?

Al Azif
Nov 1, 2006

Space Kimchi posted:

"What if all the cool new features of modern browsers to make up for the lovely statelessness of the original HTTP1.0 were REMOVED and we COULDN'T USE THEM?" Because developing web applications just isn't a huge enough timesink, I guess we need to triple our effort and put arbitrary limitations on which standard web browser features we can use. Awesome. Also, no verbs.

Statelessness isn't pointless. The most obvious benefit of REST is that it helps sites scale; you can farm out a site to many servers without having to worry about them sharing session data, and it makes your site more cacheable.

HTTP is stateless by design, not because they couldn't have come up with something better.

Also, RESTful authentication would be easy (even easier than session-based) if browsers would just get their acts together and put a decent interface on HTTP authentication.

Al Azif
Nov 1, 2006

Space Kimchi posted:

Some good replies here about REST, and I'm glad there's nobody being an insane zealot about it and having a rational discussion. Times like this it makes the $10 (times how ever many times I've been banned and bought/rebought features :v:) so worth it :)

Hey, I wish there was a well-deployed stateful protocol too; then you could do things your way and I'd do them my way and it would become pretty obvious what architecture's better for what kind of problem, and application designers could focus on their applications instead of hacking around protocol design decisions, and protocol designers could focus on solving specific problems instead of defending their design decisions.

quote:

And yeah the statelessness of HTTP is why it became popular in a way. It's just less resources and easy to set up, but I think in applications. You just can't have an application without states, it's impossible.

The trick is to keep the state on the client side; AJAX actually makes this very easy.

quote:

HTTP authentication makes your site look like it's a piece of poo poo from 1994.

It's a damned shame; blame the browsers.

Have you taken a look at continuation-based web frameworks like Seaside at all? Seems like it would be right up your alley.

Al Azif
Nov 1, 2006

copla posted:

This is my model:
code:
...
    doc.xml = REXML::Document.new File.new("/blog.xml")
    doc.xsl = REXML::Document.new File.new("/blox.xsl")
...

/blog.xml is an HTTP path, you want a path to that file on your hard drive.

quote:

I haven't had any issue opening and calling files from my stylesheets and my view files, from view I just do "/images/file.jpg" to call an image in public/images, but I can't do the same from model- when I do "/blog.xml" for it being in public/blog.xml, it doesn't work.

You know how HTML and CSS work, right? When code in a view refers to /images/something.jpeg it's not actually opening that file, it just makes a reference to it in the HTML it generates, and the user's browser requests the file.

Once you've figured out the correct path to use ("public/blog.xml" should probably work), you should just pass that straight to ruby-xslt, eg:

code:
doc.xml = "/blog.xml"
It will read and parse the file itself. There's no point in parsing it with REXML beforehand, ruby-xslt just turns it back into a string and parses that.

To process a remote file:

code:
require "open-uri"
doc.xml = open("http://example.org/some-file.xml").read

Al Azif
Nov 1, 2006
What's the usual way of setting a page's title? All my pages use the same layout, I'm assuming I should put something like this in my layout:

code:
<head>
  <title><%= @title %></title>
</head>
but should I set @title in each controller or each view?

Adbot
ADBOT LOVES YOU

Al Azif
Nov 1, 2006
Are there any guides for moving an application from 1.2 to 2.0 yet? I know there's a script that does some basic compatibility checking.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply