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

Already on GitHub? Sign in to your account

Using with acts_as_taggable_on and ActiveAdmin #849

Closed
agis opened this Issue May 14, 2012 · 3 comments

Comments

Projects
None yet
4 participants

agis commented May 14, 2012

Hi there.

I'm using ActiveAdmin with acts_taggable_on and it works fine like this:

    ActiveAdmin.register Post do
      form do |f|
        f.inputs "Details", :multipart => true do
          # bla bla more fields here
          f.input :tag_list, :label => "Tags"
        end

        f.buttons
      end
    end

Thing is, I want the user to be able to select the tags from a multi select element, and not type them on his own. So I replaced the line with this:

f.input :tag_list, :as => :select,
                     :multiple => :true,
                     :input_html => { :size => "7" },
                     :collection => Post.find(params[:id]).tag_list

but this displays only the tags that the post already has. If I change it to :collection => ActsAsTaggableOn::Tag.all then it again doesn't work as expected. Any ideas on what collection I must pass?

Owner

justinfrench commented May 15, 2012

f.input :tag_list, :as => :select,
:multiple => :true,
:input_html => { :size => "7" },
:collection => Post.find(params[:id]).tag_list

but this displays only the tags that the post already has. If I change it to :collection => ActsAsTaggableOn::Tag.all then it again doesn't work as expected. Any ideas on what collection I must pass?

In what way do you mean "doesn't work as expected" — collection should be all of the things that you can possibly choose from, so you're on the right track, but you haven't articulated how it "isn't working".

Justin

I believe you mention Model.tag_counts_on(:tags) collection

Collaborator

sobrinho commented Oct 19, 2012

You can use something like that:

f.input :tag_list, :as => :select,
                   :multiple => :true,
                   :input_html => { :size => "7" },
                   :collection => Tag.all

But you lost all the flexibility of creating new tags.

Anyway, I'm closing this issue because it's not related to formtastic.

@sobrinho sobrinho closed this Oct 19, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment