I've not used simple_form.

But looking at the docs, what you want is:

f.association :task_assignments, collection: TaskAssignment.actives

On Fri, Aug 24, 2012 at 1:24 PM, marsbomber <[email protected]> wrote:

> Hi guys,
>
> This seems to be a pretty common thing, but I just cannot figure it out
> ... I opened a thread on the simple_form group already, but I thought I'll
> ask the smart brains here too :)
>
> I have a has_many through association
>
> class User
>   has_many :task_assignments
>   has_many :tasks, through: :task_assignments
> end
>
> class TaskAssignment
>   belongs_to :user
>   belongs_to :task
>
>   scope :actives, where("disabled = ?", false)
>   scope :inactives, where("disabled = ?", true)
> end
>
> class Task
>   has_many :task_assignments
>   has_many :users, through: :task_assignments
> end
>
> On TaskAssignment, I have a disabled boolean field.
>
> On the user form, I want to list all non-disabled TaskAssignments, but by
> default
>
> f.association :task_assignments, collection: Task.all
>
> selects all assignments including the disabled ones.
>
> How do I make f.association not pre-select disabled task assignments, when
> I'm editing an existing user?
>
> Thanks
> Jim
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ruby or Rails Oceania" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/rails-oceania/-/_YQPp4CcGt0J.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/rails-oceania?hl=en.
>



-- 
Craig Read

@Catharz
https://github.com/Catharz
http://stackoverflow.com/users/158893/catharz

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
or Rails Oceania" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rails-oceania?hl=en.

Reply via email to