Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Position field #316

Closed
jlerpscher opened this Issue · 10 comments

6 participants

@jlerpscher

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

@fesplugas
Owner

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

include Typus::Controller::ActsAstList
@fesplugas fesplugas closed this
@HuffMoody

This indeed works, however small typo. Should be:

include Typus::Controller::ActsAsList

@mattherick

If I include the Typus::Controller::ActsAsList I get following error on the edit page of my model:
undefined method `model_name' for NilClass:Class
Extracted source (around line 3):
```1: <%= render "form_javascripts" %>
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?
@fesplugas
Owner

Does your model includes acts_as_list?

@mattherick

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

@spejman

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
@mattherick

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

@spejman

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

@mattherick

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

@mergulhao

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
Something went wrong with that request. Please try again.