Makund - it is quite likely that your solution will break when  
multithreading arrives (as will will loads of other stuff)

On 9-Jun-09, at 6:41 AM, Mukund wrote:

>
> Have a look at active_record::observers and wrap the save method with
> an update to the ip address.  Declare a class level variable in
> application.rb with a before_filter that populates the IP into the
> variable (and subsequently used by the observer).
>
>
>
> On Jun 9, 2:44 am, Chris <chrisn...@gmail.com> wrote:
>> As part of my project, I need to store IP address for every object
>> that was created.
>>
>>   User
>>   Topic
>>   Payment
>>   and more...
>>
>> Now all these records have the following attribute in their table
>> called "ip_address_on_create".
>>
>> One way to do this is to put this code everywhere in the controllers:
>>
>>    user.ip_address_on_create =  request.remote_ip   ,.... and so
>> forth.
>>
>> Now to conform to DRY (don't repeat yourself), I see the mechanism:
>> after_create   (model)  and after_filter ( controller).  I am not
>> really sure how to tie this thing together. Would appreciate any tips
>> or Ruby-Fu .
>>
>> Thanks in advance!
>> Chris
> >


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to