Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

In Rails 2.3, simple cell causes `wrong number of arguments (0 for 1)` #125

Closed
bikramwp opened this Issue · 5 comments

3 participants

@bikramwp

I have two questions:
First, in the README, it says that Rails 2.3 is supported via version 3.3.9. Is support for Rails 2.3 going to be available in future or are we stuck at 3.3.9 and no bug fixes or improvements?

Second, the current problem: A simple setup such as below gives me wrong number of arguments (0 for 1) :

cart_cell.rb:

class CartCell < ::Cell::Base
  def something(args)
    puts args[:param_one] # does not even get here.
    render
  end
end

Cell view cart.html.haml:

Testing Testing Testing

Call to render the cell in show view of some X controller:

= render_cell :cart, :something, :param_one => "One"

Partial stack trace:

..<myapp>/app/cells/cartcell.rb:2:in `something' 
.../gems/cells-3.3.9/lib/cells/cell/base.rb:274:in `dispatch_state'
.../cells-3.3.9/lib/cells/cell/base.rb:265:in `render_state'
.../cells-3.3.9/lib/cells/rails/action_view.rb:33:in `render_cell'

Note cartcell.rb:2:in 'something' is the line def something(args) in CartCell.

Is this a known bug or am I doing something horribly wrong?

PS I also tried the call like so but no joy:

= render_cell :cart, :something, "Pass param directly, no options hash magic"
@apotonick
Owner

Oh... I'm not sure if cells 3.3 (Rails 2.3) supports state-args at all... That answers your first question: So far I dropped 2.3 development since nobody asked for it and it is quite a bit of work. Are you tied to Rails 2.3?

@bikramwp

Yes, tied to 2.3 unfortunately.

@apotonick
Owner

Well I can take a look at how easy it is to backport stuff but for me personally it is a bit of waste of time to work on old code. Sorry dude ;)

@apotonick apotonick closed this
@brendon

Just reviving this. I'm stuck on Rails 2.3 and needed to upgrade cells from a plugin version I was using to the gem (3.3.9) to avoid deprecation warnings triggered by the plugin in Rails 2.3.6+.

I used to do this:

def my_cell
    @variable = @opts[:variable]

    render
  end

render_cell :model_name, :my_cell, :variable => whatever

I get this error now:

The error occurred while evaluating nil.[]

/cells-3.3.9/lib/cells/cell/base.rb:340:in `render_view_for'
/cells-3.3.9/lib/cells/cell/base.rb:281:in `render_view_for_backward_compat'
/cells-3.3.9/lib/cells/cell/base.rb:269:in `render_state'

I'm confused as to why this functionality (passing in variables) seems to have been either removed or is buggy? Could you let me know how I'm supposed to access variables now? I presume access changed somewhere along the line. Alternatively, is there a gem version that doesn't trigger the deprecation warnings (load_paths and returning) but still allows the old functionality?

@brendon

Turns out that I wasn't calling render in one of my cells. Slightly obscure :)

Still, @bikramwp, you can use the method I outlined above to send arguments into a cell render and access them.

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.