On Wednesday, April 27, 2011 12:25:28 PM UTC-6, DK wrote:
>
> Anyone have an idea on this? Got a weird situation where on a specific 
> model I can not create an instance using params, yet it works fine on other 
> models. The model which does not work is a stock model, there is no logic in 
> it. Ruby 1.8.7/Rails 3.0.5. 
>
> Does not work:
>
> (rdb:1) PaymentTransaction.create(:purchase_id => 3)
> #<PaymentTransaction id: 2, purchase_id: nil, action: nil, amount: nil, 
> success: nil, authorization: nil, message: nil, params: nil, created_at: 
> "2011-04-27 18:18:59", updated_at: "2011-04-27 18:18:59">
>
> But this works (but is ugly):
>
> (rdb:1) bpt = PaymentTransaction.new
> #<PaymentTransaction id: nil, purchase_id: nil, action: nil, amount: nil, 
> success: nil, authorization: nil, message: nil, params: nil, created_at: 
> nil, updated_at: nil>
> (rdb:1) bpt.purchase_id = 3
> 3
> (rdb:1) bpt.save
> true
> (rdb:1) PaymentTransaction.find_by_bet_id(3)
> #<PaymentTransaction id: 3, purchase_id: 3, action: nil, amount: nil, 
> success: nil, authorization: nil, message: nil, params: nil, created_at: 
> "2011-04-27 18:22:46", updated_at: "2011-04-27 18:22:46">
>
>
> And this works:
>
> (rdb:1) Team
> Team(id: integer, sport_id: integer, name: string, created_at: datetime, 
> updated_at: datetime)
> (rdb:1) Team.create(:sport_id => 5, :name => 'xxxx')
> #<Team id: 1, sport_id: 5, name: "xxxx", created_at: "2011-04-27 18:18:31", 
> updated_at: "2011-04-27 18:18:31">
>
>
You don't have something like:

  attr_protected :puchase_id

in your PaymentTransaction model do you?

[http://api.rubyonrails.org/classes/ActiveModel/MassAssignmentSecurity/ClassMethods.html#method-i-attr_protected]
 

-- 
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