What does this code do?
- by Senthil
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