Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lets Rate gem with field_for #33

Open
wazery opened this issue Jul 30, 2014 · 0 comments
Open

Lets Rate gem with field_for #33

wazery opened this issue Jul 30, 2014 · 0 comments

Comments

@wazery
Copy link
Owner

wazery commented Jul 30, 2014

Issue by railsfactory-bharani
Thursday May 29, 2014 at 16:23 GMT
Originally opened as muratguzel#71


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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant