Ruby on Rails
Saturday, February 8, 2014
Is this 2 methods inside of which files?
-- To start I dont see the point of the select here:
oa =OrderAsset.select("order_assets.*").where("order_detail_id =
#{od_id}")
#{od_id}")
this is the same as
oa =OrderAsset.where("order_detail_id =
#{od_id}")
#{od_id}")
Second thing, you should use a scope for this on the model!
Third:
The way you should call them are completly wrong! one returns a collection of assets the other one returns an asset.
I also dont understand why you are defining class methods for an helper(maybe you have a good reason).
So the first one that returns a collection you should actually giving a name to it like:
(you should use scopes again but now I just wanna give you a naming example)
def get_order_assets_from_detail
and the other one:
def get_order_asset_from_detail
you see the difference on the s?
I hope you understand what I mean, but I think you need to look more into scopes and how to create decorators! It will give you an insight of what you should put in a decorator, a model and in a helper!
all the best,
Andre
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/497cb33f-4c36-49c6-b908-e542c05a7259%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment