muratguzel / letsrate

The best way to add rating capabilities to your rails application and your activerecord models.
http://letsrate.herokuapp.com
198 stars 234 forks source link

Lets Rate gem with field_for #71

Open agiratech-bharani opened 10 years ago

agiratech-bharani commented 10 years ago

I am new to letsrate gem and also saw existing bugs. No one post the issue like this. In order to avoid ajax call, I am customized letsrate.js.erb for form submission. Setting the values of letsrate scores, dimensions and klass in hidden fields. Till now everything works fine for me.

In Review model: letsrate_rateable "speed"

In letsrate.js.erb: click: function(score, evt) { var _this = this; $("#business_rate_score").attr("value", score); $("#business_rate_dimension").attr("value", $(this).attr('data-dimension')); $("#business_rate_klass").attr("value", $(this).attr('data-classname')); } When am trying to use field_for and use those hidden fields like this: <%= f.fields_for :rates do |g| %> input type='hidden' id="business_rate_score" name="score" input type='hidden' id="business_rate_dimension" name="dimension" input type='hidden' id="business_rate_klass" name="klass" <% end %>

For making nested_attributes in Review model: letsrate_rateable "speed" accepts_nested_attributes_for :rates, :allow_destroy => true

It throws No association found for name `rates'. Has it been defined yet? (ArgumentError)

Is letsrate gem accepting nested attributes? Can you explain me to make nested attributes to save the values?