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
vg8000
Feb 6, 2003

You never question Heylia's eyeballing. That's the rainman of weed right there.

atastypie posted:

Hobo is brand new, so there is very little up to date documentation let alone an entire book. You could print off the docs from the website and reference those instead.

I have a problem that I am sure is actually really simple: I want to add up and return a total price across a m2m association. Using the generic example, I want to be able to add up the total price of all Books based on an Author.

Author
habtm :books

Book
habtm :authors
t.column "price", :integer

Can anyone help me out?
code:
@author = Author.find(params[:author_id])
@total_price = @author.books.inject { |sum, book| sum + book.price }

There's probably a better way to do this that doesn't involve so many behind-the-scenes DB calls but I can't think of it right now...

vg8000 fucked around with this message at 13:26 on Aug 23, 2007

Adbot
ADBOT LOVES YOU

Fork
Aug 5, 2004
@author.books.sum(&:price)

(Although I think it's functionally identical to the above example)

nebby
Dec 21, 2000
resident mog
You probably want to use :include to join in all the books when you fetch the author.

hmm yes
Dec 2, 2000
College Slice
Thanks for the replies, I've got it working :)

cYp
Apr 16, 2007

I'm either going to get started learning PHP or Ruby on rails. I'm currently leaning towards php. Will this be a mistake in the future?

vg8000
Feb 6, 2003

You never question Heylia's eyeballing. That's the rainman of weed right there.

cYp posted:

I'm either going to get started learning PHP or Ruby on rails. I'm currently leaning towards php. Will this be a mistake in the future?
PHP is probably the worst language to start with. It's got widespread support, but there's so much cruft that comes from not being very well designed in the first place. Go with Ruby or Python.

Mrs. Wynand
Nov 23, 2002

DLT 4EVA

cYp posted:

I'm either going to get started learning PHP or Ruby on rails. I'm currently leaning towards php. Will this be a mistake in the future?

Well you can either learn RoR which encourages you (but doesn't guarantee you to) use good programming practices and will (after some experience behind your belt) get you working on cool projects with people that (on average, compared to php) know what they doing, and you'll be set to head into all sorts of new directions (the skills you learn apply everywhere, even PHP dev).

Or you can learn PHP, write lovely code (which everyone always does when they start of, but...), never grow out of it, beg for poo poo work from rent-a-coder while competing against half of asia, grow insane with the cluster-gently caress of code you'll usually have to deal with and the people that wrote it, until you eventually decide you either need to take up accounting or learn a new programming skill.

It's not PHP itself that is the problem (... for the most part...), it's the environment that grew around it. It is not always the case, but most PHP 'careers' tend towards nasty, brutish and short.

It also doesn't have to be Rails you start with. Python, Perl, even Java (The Great Satan for most rails peeps) are all much more useful to learn. You could also jump into the really really really deep end and start by learning Haskell. It's not for the faint of heart but if you can gork Haskell, anything else you learn will be a walk in the park. ( it is also somewhat easier to learn haskell as your first language rather then your second or subsequent one).

Vulture Culture
Jul 14, 2003

I was never enjoying it. I only eat it for the nutrients.

Mr. Wynand posted:

It also doesn't have to be Rails you start with. ... Perl
This was my first language and dear loving God do not do this

you will never fix all the damage

Mrs. Wynand
Nov 23, 2002

DLT 4EVA

Mr. Heavy posted:

This was my first language and dear loving God do not do this

you will never fix all the damage

still better then php

floWenoL
Oct 23, 2002

Mr. Wynand posted:

still better then php

true dat

drjrock_obgyn
Oct 11, 2003

once i started putting pebbles in her vagina, there was no going back

atastypie posted:

Hobo is brand new, so there is very little up to date documentation let alone an entire book. You could print off the docs from the website and reference those instead.

I have a problem that I am sure is actually really simple: I want to add up and return a total price across a m2m association. Using the generic example, I want to be able to add up the total price of all Books based on an Author.

Author
habtm :books

Book
habtm :authors
t.column "price", :integer

Can anyone help me out?

Out of curiosity, why are you using habtm instead of has_many in this situation? This looks like an instance where an author should have many books and a book belong to an author. Your domain may be a bit different though. Anyway, you should just be able to do the following:

author = Author.find(:first)
price = author.books.sum(:price)

However, you would want to do something like this:

Models:
code:
class Author < ActiveRecord::Base
  has_many :books do
    def all_books(args)
      find(:all, args)
    end

    def total_price(reload=false)
      @total_price = nil if reload
      @total_price ||= sum(:price)
    end
  end
end

class Book < ActiveRecord::Base
  belongs_to :author
end
Controller (figuring you're doing a list of some sort)
code:
before_filter :find_author
private
  def find_author
    @author = Author.find(params[:author_id])
  end

public
  def index
    @books = @author.books.all_books
    @total_price = @author.books.total_price
  end
Your views you would just reference the @books and @total_price objects. This also assumes that you would be looking at your books based on the route of /authors/:author_id/books.

Not sure what reasons you have for making price an integer, but it could be a decimal column as well. See http://pragdave.pragprog.com/pragdave/2006/07/decimal_support.html.

crazysim
May 23, 2004
I AM SOOOOO GAY
Many books have multiple authors. There are so many real world examples on this that I don't even know where to start with an example. I'm just a newbie, but habtm on first glance would make sense to me on that.

vg8000
Feb 6, 2003

You never question Heylia's eyeballing. That's the rainman of weed right there.

crazysim posted:

Many books have multiple authors. There are so many real world examples on this that I don't even know where to start with an example. I'm just a newbie, but habtm on first glance would make sense to me on that.

There's also has_many :through, which can let you flesh out the relationship a more than a habtm can.

dustgun
Jun 20, 2004

And then the doorbell would ring and the next santa would come

cYp posted:

I'm either going to get started learning PHP or Ruby on rails. I'm currently leaning towards php. Will this be a mistake in the future?
Learn Ruby, then Ruby on Rails.

scr0llwheel
Sep 11, 2004
ohelo
So I'm thinking of starting a project with RoR but have one question: Is there a suitable way to do user registration, authentication, etc? Granted, I haven't looked into it very much, but all authentication stuff seems to be either the entire site or nothing. What I'd specifically like to do is to protect an admin control panel along with admin-only elements/controls on an otherwise publicly viewable page.

Is this built into RoR and I just missed it? Are there any gems available to do this? How hard is this to implement?

vg8000
Feb 6, 2003

You never question Heylia's eyeballing. That's the rainman of weed right there.

scr0llwheel posted:

So I'm thinking of starting a project with RoR but have one question: Is there a suitable way to do user registration, authentication, etc? Granted, I haven't looked into it very much, but all authentication stuff seems to be either the entire site or nothing. What I'd specifically like to do is to protect an admin control panel along with admin-only elements/controls on an otherwise publicly viewable page.

Is this built into RoR and I just missed it? Are there any gems available to do this? How hard is this to implement?

There's a plugin called restful_authentication that's pretty much the standard if you're not going to write something custom. It'll give you all the username/password/login/session stuff, and you can build from that.

HIERARCHY OF WEEDZ
Aug 1, 2005

In C# I have the '??' operator, which when used like 'a ?? b', returns a unless it is a null object, in which case it returns b. Is there anything like that in Ruby?

EDIT: Wow, ignore that. I was retarded. My original question still stands.

HIERARCHY OF WEEDZ fucked around with this message at 00:27 on Aug 29, 2007

freeb0rn
Jan 22, 2005

shopvac4christ posted:

In C# I have the '??' operator, which when used like 'a ?? b', returns a unless it is a null object, in which case it returns b. Is there anything like that in Ruby?

EDIT: Wow, ignore that. I was retarded. My original question still stands.
The or operator (||) in Ruby can work like this.

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense

scr0llwheel posted:

So I'm thinking of starting a project with RoR but have one question: Is there a suitable way to do user registration, authentication, etc? Granted, I haven't looked into it very much, but all authentication stuff seems to be either the entire site or nothing. What I'd specifically like to do is to protect an admin control panel along with admin-only elements/controls on an otherwise publicly viewable page.

Is this built into RoR and I just missed it? Are there any gems available to do this? How hard is this to implement?

If all you need is one admin user then you don't need restful_authentication, this is much simpler and should fulfill your need:

Controller:
code:
  def login
    if request.post?
      if params[:login] == "admin" and params[:password] == "admin_pw"
        session[:logged_in] = true
        redirect_to admin_page_url
      end
    end
  end
  
  def logout
    session[:logged_in] = nil
    redirect_to :action => "login"
  end
ApplicationController:
code:
  def logged_in?
     return session[:logged_in] ? true : false
  end
  helper_method :logged_in?
Then use "if logged_in?" anywhere that you want.

Nolgthorn fucked around with this message at 03:13 on Aug 29, 2007

smackfu
Jun 7, 2004

Rails makes me cry when I look at the SQL calls. I mean, it's very easy to get a working application, but then you wonder why it's slow, and it's because it's doing 100 db calls for a 100 item list. Oy.

Given that, I did write a whole website in it, and it has actual users who aren't me. And I haven't touched it in 6 months and it's still working, so not bad.

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense

smackfu posted:

Rails makes me cry when I look at the SQL calls. I mean, it's very easy to get a working application, but then you wonder why it's slow, and it's because it's doing 100 db calls for a 100 item list. Oy.

You're right it's not perfect but you also have to use it properly.

@authors = Authors.find(:all, :include => ["books", {"screenplays" => "movie"}])

If the application is making 100 db calls for a 100 item list then you have forgotten to use eager loading. Now you can loop through, request the author.books or whatever and it won't have to get that information from the database for each one.

Edit: Sorry, not intended to sound mean.

Nolgthorn fucked around with this message at 07:15 on Aug 30, 2007

HIERARCHY OF WEEDZ
Aug 1, 2005

freeb0rn posted:

The or operator (||) in Ruby can work like this.

:doh: Should have thought of that.

Also, holy crap Hobo is a huge framework. The stack traces are twice as long and I haven't even started *coding* yet. I think this may be too much magic for what I'm trying to do.

Space Kimchi
Jan 7, 2007

by Peatpot
I've been trying to learn Ruby on Rails on and off for a while, and I'm back on an ON kick again. :)

I'm working on something that I'd want to have a forums auth for; I've written one in PHP before and it requires setting a cookie and setting your own HTML headers and everything (you can't view profiles without being logged in). How would I even begin to try this in RoR?

Also a lot of the AJAX stuff is nice but good lord is it black magic. I follow little tutorials on how to do stuff and it just says "put this here" and I do but I have no idea WHY. I've written AJAX applications by hand before, writing my own xmlhttprequests and response scripts, so I get the mechanics of it but I am having a hard time figuring out how to get to the point in RoR where I can say, "ok I want an AJAX thing to do this, so I'd have to write code with this structure and syntax:".

Pardot
Jul 25, 2001




Space Kimchi posted:

Also a lot of the AJAX stuff is nice but good lord is it black magic.

Start with using the rjs templates and what not. Then start to actually learn Javascript and Prototype. I'm on the second step currently, and while I might not be the best javascript guy, I know what's going on and it doesn't feel like black magic anymore.

And if you ever are wondering why something works the way it does in rails, start reading the rails source code. It's not that scary, I promise. :)

Space Kimchi
Jan 7, 2007

by Peatpot

Anal Wink posted:

Start with using the rjs templates and what not. Then start to actually learn Javascript and Prototype. I'm on the second step currently, and while I might not be the best javascript guy, I know what's going on and it doesn't feel like black magic anymore.

And if you ever are wondering why something works the way it does in rails, start reading the rails source code. It's not that scary, I promise. :)

It's more like, I don't get the logic at all behind the requests and responses. Indeed, I probably need to "get" Prototype more. I'll just have to play with it a bit, I think last time I was messing with it I started examining the xmlhttprequests and everything and figured out what it was doing and it started to make SOME sense.

Argue
Sep 29, 2005

I represent the Philippines
Speaking of AJAX, is there some kind of way to retrieve an instance of a model as a javascript object? I mean, if you have a model called Book, and it has the fields title, description, ISBN, is there a function that will let me go myBook = theFunction(myBookId), such that I can say myBook.title, etc?

savetheclocktower
Sep 23, 2004

You wait and see, Mr. Caruthers. I will be president! I'll be the most powerful president in the history of America. And I'm gonna clean up this country!

Space Kimchi posted:

It's more like, I don't get the logic at all behind the requests and responses. Indeed, I probably need to "get" Prototype more. I'll just have to play with it a bit, I think last time I was messing with it I started examining the xmlhttprequests and everything and figured out what it was doing and it started to make SOME sense.

If you aren't using Firebug, start. That's step one, step two, and step three.

Argue posted:

Speaking of AJAX, is there some kind of way to retrieve an instance of a model as a javascript object? I mean, if you have a model called Book, and it has the fields title, description, ISBN, is there a function that will let me go myBook = theFunction(myBookId), such that I can say myBook.title, etc?

Jester does this. Looks cool, but I haven't tried it personally.

Space Kimchi
Jan 7, 2007

by Peatpot

savetheclocktower posted:

If you aren't using Firebug, start. That's step one, step two, and step three.

You mean there's another way to do that? ;D

And god dammit, I never thought that my problem writing an SA auth would be more with "how do i functioned ruby" than "how do i grabbed something with cookies"

For the curious, here's what I have so far. The page nabbing works great, but I wanted to test my newly-added logic and whatnot. Note that the cookie is copied and pasted directly from the Cookie: line in the HTTP headers when I normally visit a page, on SA all of them. When I wrote a PHP one, I discovered that being selective doesn't work too well. Of course since you could use that to log in as me, I have removed it :v:

code:
module AuthHelper
  
  def authprofile(username, authstring, mode)
    username = CGI.escape(username)
    @cookie = "THIS IS MY COOKIE. THERE ARE MANY LIKE IT, BUT THIS ONE IS MINE."
    http = Net::HTTP.new('forums.somethingawful.com', 80)
    http.start do |http|
      request = Net::HTTP::Get.new('/member.php?action=getinfo&username='+username)
      request.add_field 'Cookie', @cookie
      response = http.request(request)
      response.value
      @page = response.body
    end
    
    if @page.include? authstring
      if mode=="there"
        return true
      else
        return false
      end
    else
      if mode=="there"
        return true
      else
        return false
      end
    end
    
  end
end

The wacky logic at the end is for my future plans to have a "now remove this from your profile" portion and all that, and just have one function handle all of it.

Now I'd love to test it on my ruby script/console deal, but I can't figure out how to invoke it :( Should this kind of thing be in Helpers? Oh god MVC :psyduck:

Edit: fixed some syntax after I had a chance to test it, I have to include the helper in script/console :v: Now I just have to figure out why it returns true no matter what now when it worked before!

Space Kimchi fucked around with this message at 10:14 on Aug 30, 2007

crazysim
May 23, 2004
I AM SOOOOO GAY
This is just wild guessing and from playing with ruby.

code:
irb(main):055:0> mode = "there"
=> "there"
irb(main):056:0> authprofile(user,authstring,mode)
=> true
irb(main):057:0> mode = "smell"
=> "smell"
irb(main):058:0> authprofile(user,authstring,mode)
=> false
I don't know what you want to do with mode though.

Space Kimchi
Jan 7, 2007

by Peatpot

crazysim posted:

This is just wild guessing and from playing with ruby.

code:
irb(main):055:0> mode = "there"
=> "there"
irb(main):056:0> authprofile(user,authstring,mode)
=> true
irb(main):057:0> mode = "smell"
=> "smell"
irb(main):058:0> authprofile(user,authstring,mode)
=> false
I don't know what you want to do with mode though.

Yeah I got rid of mode, it was a dumb idea.

code:
module AuthHelper
  
  def authprofile(username, authstring)
    username = CGI.escape(username)
    @cookie = "MY COOKIE"
    http = Net::HTTP.new('forums.somethingawful.com', 80)
    http.start do |http|
      request = Net::HTTP::Get.new('/member.php?action=getinfo&username='+username)
      request.add_field 'Cookie', @cookie
      response = http.request(request)
      response.value
      @page = response.body
    end
    
    return @page.include?(authstring)
    
  end
end
This seems to work. My only concern is, coming from a PHP background, would this leave any room for the user to put in something stupid and break my app or get me banned without any further filtration?

Edit: Also I must say, I'm impressed. I remember the equivalent PHP code being bigger, clunkier, and a bigger pain in the rear end to figure out; I had to send a WHOLE raw HTTP request, if I recall, or at least I remember it took a while to figure out it wasn't working because of the lack of the proper number of newlines after the Cookie: line, heh.

Edit2: And I confess I mostly lifted the net code from some tutorial or snippet I found and figured out how to add cookies and adjusted it to my nefarious means. In other words, don't ask me what response.value is or what it does, as I don't know. Or even EXACTLY why it's in a do|| loop, as I can only vaguely guess.

Space Kimchi fucked around with this message at 11:04 on Aug 30, 2007

Pardot
Jul 25, 2001




Space Kimchi posted:

Oh god MVC :psyduck:

I don't think making it a helper is the right thing to do. This either wants to be its own class which would live in app/models (if you wanted to be all restful about it) or a class in lib.

MonkeyMaker
May 22, 2006

What's your poison, sir?
Is anyone doing RailsRumble (railsrumble.com)? A team of four of us at my work are.

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?

Scarboy
Jan 31, 2001

Good Luck!

Al Azif posted:

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?

before_filter :get_session_user

Then in application.rb make a private method that does @user = find_user.

Space Kimchi
Jan 7, 2007

by Peatpot

Space Kimchi posted:


This seems to work. My only concern is, coming from a PHP background, would this leave any room for the user to put in something stupid and break my app or get me banned without any further filtration?

Just to make it clear, I'm really hoping for more response to this, as I'm used to being Fort Knox with PHP and I'm not sure what I have to do or how careful I have to be in Rails.

And thanks Wink, making it a Model class sounds like a good idea. RESTzis can pretty much suck it imo, I'm keeping my verbs god dammit. I never liked the stateless nature of HTTP anyway. If you do, that's great, I just don't care and am going to use all the goddamned verbs and session cookies I please.

HIERARCHY OF WEEDZ
Aug 1, 2005

What's a good way to figure out which submit button on a form was clicked if all of them have the same name?

hmm yes
Dec 2, 2000
College Slice

shopvac4christ posted:

What's a good way to figure out which submit button on a form was clicked if all of them have the same name?

Not entirely sure if this is the solution you need, but the with action plugin lets you easily use multiple buttons within a form. You would be able to give each button it's own name.

Mrs. Wynand
Nov 23, 2002

DLT 4EVA

Argue posted:

Speaking of AJAX, is there some kind of way to retrieve an instance of a model as a javascript object? I mean, if you have a model called Book, and it has the fields title, description, ISBN, is there a function that will let me go myBook = theFunction(myBookId), such that I can say myBook.title, etc?

Jester is prolly overkill - just use @book.to_json

MrSaturn
Sep 8, 2004

Go ahead, laugh. They all laugh at first...
I just broke something when I updated rails from the gem [to edge rails] and I can't figure on how to fix it.... here's what my error log shows:

code:
DISPATCHER FAILSAFE RESPONSE (has cgi) Mon Sep 03 11:35:23 -0400 2007
  Status: 500 Internal Server Error
  A secret is required to generate an integrity hash for cookie session data. Use config.action_controller.session = { :session_key => "_myapp_session", :secret => "some secret phrase" } in config/environment.rb
    C:/ruby/rails_apps/jivewise2/vendor/rails/actionpack/lib/action_controller/session/cookie_store.rb:54:in `initialize'
    C:/ruby/ruby/lib/ruby/1.8/cgi/session.rb:273:in `new'
    C:/ruby/ruby/lib/ruby/1.8/cgi/session.rb:273:in `initialize_without_cgi_reader'
    C:/ruby/rails_apps/jivewise2/vendor/rails/actionpack/lib/action_controller/cgi_ext/session.rb:29:in `initialize'
    C:/ruby/rails_apps/jivewise2/vendor/rails/actionpack/lib/action_controller/cgi_process.rb:124:in `new'
    C:/ruby/rails_apps/jivewise2/vendor/rails/actionpack/lib/action_controller/cgi_process.rb:124:in `session'
    C:/ruby/rails_apps/jivewise2/vendor/rails/actionpack/lib/action_controller/cgi_process.rb:156:in `stale_session_check!'
    C:/ruby/rails_apps/jivewise2/vendor/rails/actionpack/lib/action_controller/cgi_process.rb:111:in `session'
    C:/ruby/rails_apps/jivewise2/vendor/rails/actionpack/lib/action_controller/base.rb:1117:in `assign_shortcuts_without_flash'
    C:/ruby/rails_apps/jivewise2/vendor/rails/actionpack/lib/action_controller/flash.rb:174:in `assign_shortcuts'
    C:/ruby/rails_apps/jivewise2/vendor/rails/actionpack/lib/action_controller/base.rb:488:in `process_without_filters'
    C:/ruby/rails_apps/jivewise2/vendor/rails/actionpack/lib/action_controller/filters.rb:683:in `process_without_session_management_support'
    C:/ruby/rails_apps/jivewise2/vendor/rails/actionpack/lib/action_controller/session_management.rb:122:in `process'
    C:/ruby/rails_apps/jivewise2/vendor/rails/actionpack/lib/action_controller/base.rb:346:in `process'
    C:/ruby/rails_apps/jivewise2/vendor/rails/railties/lib/dispatcher.rb:39:in `dispatch'
    C:/ruby/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel/rails.rb:78:in `process'
    C:/ruby/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel/rails.rb:76:in `synchronize'
    C:/ruby/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel/rails.rb:76:in `process'
    C:/ruby/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel.rb:618:in `process_client'
    C:/ruby/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel.rb:617:in `each'
    C:/ruby/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel.rb:617:in `process_client'
    C:/ruby/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel.rb:736:in `run'
    C:/ruby/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel.rb:736:in `initialize'
    C:/ruby/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel.rb:736:in `new'
    C:/ruby/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel.rb:736:in `run'
    C:/ruby/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel.rb:720:in `initialize'
    C:/ruby/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel.rb:720:in `new'
    C:/ruby/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel.rb:720:in `run'
    C:/ruby/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel/configurator.rb:271:in `run'
    C:/ruby/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel/configurator.rb:270:in `each'
    C:/ruby/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel/configurator.rb:270:in `run'
    C:/ruby/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/bin/mongrel_rails:127:in `run'
    C:/ruby/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel/command.rb:211:in `run'
    C:/ruby/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/bin/mongrel_rails:243
    C:/ruby/ruby/bin/mongrel_rails:16:in `load'
    C:/ruby/ruby/bin/mongrel_rails:16
It looks like I have to set some keyword for my cookie? Where and how do I do that?

Adbot
ADBOT LOVES YOU

skidooer
Aug 6, 2001

MrSaturn posted:

It looks like I have to set some keyword for my cookie? Where and how do I do that?
A secret is required to generate an integrity hash for cookie session data. Use config.action_controller.session = { :session_key => "_myapp_session", :secret => "some secret phrase" } in config/environment.rb ;)

In other words, stick that line in the config section of your environment file. And change the key and secret values.

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