What does this code do?

Posted by Senthil on Stack Overflow See other posts from Stack Overflow or by Senthil
Published on 2010-04-16T05:11:47Z Indexed on 2010/04/16 5:13 UTC
Read the original article Hit count: 412

Filed under:
|

I found this in Ryan Bates' railscast site, but not sure how it works.

#models/comment.rb
def req=(request)
self.user_ip    = request.remote_ip
self.user_agent = request.env['HTTP_USER_AGENT']
self.referrer   = request.env['HTTP_REFERER']
 end

#blogs_controller.rb
def create
 @blog = Blog.new(params[:blog])
 @blog.req = request
 if @blog.save
 ...

I can sort of understand what he is doing. But am confused with the req=(request) line. Any help is appreciated.

Thanks

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about railscasts