We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
So i have the following model
class Category include Mongoid::Document field :slug, type: String embeds_many :translations embeds_many :segments accepts_nested_attributes_for :translations, :reject_if => :all_blank, :allow_destroy => true end
and in my HTML using simple_form, i have the following:
<%= simple_form_for @category do |f| %> <%=f.input :slug, label: 'Slug', required: true %> <%= f.submit class:'btn btn-primary text-uppercase' %> <div class="col-sm-12"> <div class="card"> <div class="card-header"> <div class="row"> <div class="col-sm-12"> <i class="fa fa-align-justify"></i>Translation <%=link_to_add_association f, :translations, partial: 'shared/translation', 'data-association-insertion-method' => 'append' do %> <span class="right"> <i class="icon-add-new"></i> Add Translation </span> <% end %> </div> </div> </div> <div class="card-body"> <div id="translations" class="row"> <%= f.simple_fields_for :translations do |translation| %> <%= render 'shared/translation', f: translation %> <% end %> <div class="clear"></div> </div> </div> </div> </div> <%end %>
In my controller. i have this
def new @category = Category.new end
But whenever i try to load the new.html.erb, this block of code
<%=link_to_add_association f, :translations, partial: 'shared/translation', 'data-association-insertion-method' => 'append' do %> <span class="right"> <i class="icon-add-new"></i> Add Translation </span> <% end %>
triggers this error
ActionView::Template::Error (uninitialized constant Category::Translation):
I looked at the view_helper module and noticed it is this method
def create_object_with_conditions(instance) conditions = instance.respond_to?(:conditions) ? instance.conditions.flatten : [] instance.klass.new(*conditions) end
or specifically this line instance.klass.new(*conditions)
instance.klass.new(*conditions)
Not sure how to overcome this issue. Seems like it doesnt realize the embeds_many association.
Any assistance is appreciated.
The text was updated successfully, but these errors were encountered:
Personally never used it Mongoid, could you explain: is there a Translation class? Should there not be?
Translation
What is an embed_many and how would you "create" an instance of a :translation instead?
embed_many
:translation
Sorry, something went wrong.
No branches or pull requests
So i have the following model
and in my HTML using simple_form, i have the following:
In my controller. i have this
But whenever i try to load the new.html.erb, this block of code
triggers this error
ActionView::Template::Error (uninitialized constant Category::Translation):
I looked at the view_helper module and noticed it is this method
or specifically this line
instance.klass.new(*conditions)
Not sure how to overcome this issue. Seems like it doesnt realize the embeds_many association.
Any assistance is appreciated.
The text was updated successfully, but these errors were encountered: