Position field #316

Closed
jlerpscher opened this Issue Oct 20, 2011 · 10 comments

Comments

Projects
None yet
6 participants

Hello,

A few months ago, I asked for help to use a field 'position' with Typus. Today I have the problem again. I have new actions in typus "Top / Up / Down / Bottom". Unfortunately, I have a beautiful "The action 'position' could not be found for Admin::ProjectsController" message when I try to click it. I have try to add acts_as_list gem but I have still my error.

Thank you

Owner

fesplugas commented Oct 20, 2011

On the required controller you need to include the ActsAsList module:

include Typus::Controller::ActsAstList

fesplugas closed this Oct 20, 2011

This indeed works, however small typo. Should be:

include Typus::Controller::ActsAsList

If I include the Typus::Controller::ActsAsList I get following error on the edit page of my model:
undefined methodmodel_name' for NilClass:Class`
Extracted source (around line 3):

2: 
3: <%= form_for @item, :url => options, :html => { :class => "resource", :multipart => true } do |form| %>
4: 
5:   <%= render "helpers/admin/resources/errors" %>
6:

If I comment out the include, everthing works in the edit action.

Anyone an idea how to fix this?

Owner

fesplugas commented Dec 14, 2011

Does your model includes acts_as_list?

Yes it does. And I already included the gem acts_as_list itself in the Gemfile.

Contributor

spejman commented Jan 8, 2012

I think that this problem is a little bug in https://github.com/fesplugas/typus/blob/master/lib/typus/controller/acts_as_list.rb line 6 and 7.

Can be solved adding:

  before_filter :get_object, :only => Whitelist + [:show, :position]
  before_filter :check_resource_ownership, :only => Whitelist + [:position]

after:

  include Typus::Controller::ActsAsList

Ok if I do the tings @spejman said I get following error:
undefined method "move_lower"

Contributor

spejman commented Jan 11, 2012

@mattherick you have to add acts_as_list in your model in order to have move_* methods in the object.

Ah I already did that, but in the wrong model :-). Thanks, now it works!

Contributor

mergulhao commented Jun 6, 2012

This issue is still happening. Confirmed with typus v3.1.10 and acts_as_list v0.1.6. Trick from @spejman works for me.

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