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

喜欢而已 提交于 2019-12-13 07:26:58

问题


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?

来源:https://stackoverflow.com/questions/34561256/rails-4-acts-as-taggable-on-gem-set-up-errors

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!