Ruby on Rails Monday, January 2, 2012

#gem 'rails', '3.0.9'
#gem "paperclip", "~> 2.0"

rails console
>contract = Contract.first
=> #<Contract id: 1, . . .
>files = contract.contract_files
=> [#<ContractFile id: 1, contract_id: 1, . . .
>files.first.data.url
=> "/system/data/1/original/logo.png?1325513082"
> files.map(&:data_file_name).each do |key| key end
=> ["logo.png", "newyearseve-2011-res.jpg", nil]
#IT WORKS FINE!


> files.map(&:data.url).each do |key| key end
=> NoMethodError: undefined method `url' for :data:Symbol
#IT DOESN'T WORK

Can you explain how to get access to "data.url" in has_many model?


--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

No comments:

Post a Comment