Nevermind found out. You cannot use p for a column name
-----Original Message-----
From: [email protected]
[mailto:[EMAIL PROTECTED] On Behalf Of tyliong
Sent: Sunday, September 07, 2008 11:26 PM
To: Ruby on Rails: Talk
Subject: [Rails] Re: Seriously stumped cannot call attribute out
this is what it says in console
>> Groceries.find(1).supermarket.p
ArgumentError: wrong number of arguments (0 for 1)
from /usr/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/
active_record/associations/association_proxy.rb:177:in `p'
from /usr/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/
active_record/associations/association_proxy.rb:177:in `send'
from /usr/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/
active_record/associations/association_proxy.rb:177:in
`method_missing'
from (irb):30
On Sep 7, 11:14 pm, tyliong <[EMAIL PROTECTED]> wrote:
> Hi, i am having problems displaying a simple attribute. what is weird
> is that all the other attributes are can be called but not .p . I
> have been racking my brain on why but I just don't get it. it doesn't
> make sense i can call nearly every attribute except this one
>
> DB creation code:
>
> create_table :supermarket do |t|
> t.integer :groceries_id
> t.decimal :price, :precision => 8, :scale => 2
> t.integer :p
> t.decimal :numindeal, :precision => 8, :scale => 2
> t.decimal :promprice, :precision => 8, :scale => 2
> t.timestamps
> end
>
> Table
>
> id |groceries_id |price|p|numindeal|promprice|
> 1 |1| |3.00|1|3.00 ||3.00 |
>
> Helper.rb
>
> def pricecheck(groceries,supermarket)
> z = groceries.send(supermarket)
>
> z.groceries_id
> z.price
> z.numindeal
> z.promprice {all these work}
> z.p {this gives "wrong number of arguments (0 for 1)"}
> end
>
> view code:
>
> <%= pricecheck(groceries,"supermarket") %>
--~--~---------~--~----~------------~-------~--~----~
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 [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---