I have two attributes, 'a_value' and 'b_id'. (Not their real names.) 'a_value' is stored on the file system, using some information from model 'B', referenced by 'b_id'.
So, my params object looks like:
params[:foo] = {"a_value"=>"nifty value","b_id"=>"38"}
for example.
Now, in foo_controller.rb:
foo = Foo.new(params[:foo])
But this fails with.
ActiveRecord::RecordNotFound: Couldn't find Foo without an ID
In Foo.a_value=(value) I have
...
self.my_path = self.b_id.the_path
...
It looks like Rails is doing the assignments in alphabetical order and panicking when b_id isn't there, even though it's present in the params hash and passes validation.
Can I force the order in which this assignment is done? Or can I create a before_filter that will do the b_id assignment before the remainder of the mass assignment happens?