Rails 4 - Acts as Taggable on gem - set up errors

2019-09-02 15:05发布

I am trying to make an app with Rails 4.

I am trying to use gem 'acts-as-taggable-on', '~> 3.4'

I found this tutorial showing how to set it up:

https://www.reddit.com/r/rails/comments/2chtgw/tagging_in_rails_4/

I have an articles controller, which has included tag_list in the strong params:

def article_params
      params[:article].permit(:user_id, :body, :title, :image, :tag_list,
        comment_attributes: [:opinion])
    end

I have an articles form, with:

<%= simple_form_for(@article) do |f| %>
            <%= f.error_notification %>

                <div class="form-inputs">
                    <%= f.input :title,  autofocus: true %>
                    <%= f.input :body, :label => "Post", :input_html => {:rows => 10} %>
                    <%= f.input :image, :label => "Add an image" %>
                    <%= f.input :tag_list, :label => "Add tags" %>
                </div>

                <div class="form-actions">
                    <%= f.button :submit, "Submit & Publish", :class => 'formsubmit' %>
                </div>
        <% end %>

I have the table in my schema and have completed all the steps prior to the view integration in the reddit post.

When I try to check the form is working, I get this error:

undefined method `tag_list' for #<Article:0x007fad26cd9f30>

Can anyone see what's going wrong?

0条回答
登录 后发表回答