xtremelabs / xl-passbook-ruby

Apache License 2.0
16 stars 10 forks source link

Rails 4 #14

Open Sjors opened 11 years ago

Sjors commented 11 years ago

When I run the pass generator I get the following error, probably because I'm using Rails 4.0.0rc1 on ruby 2.0.0:

/Users/sjors/.rvm/gems/ruby-2.0.0-p0/gems/actionpack-4.0.0.rc1/lib/action_dispatch/routing/mapper.rb:239:in `default_controller_and_action': 'Passbook::passes' is not a supported controller name. This can lead to potential routing problems. See http://guides.rubyonrails.org/routing.html#specifying-a-controller-to-use (ArgumentError)

Sjors commented 11 years ago

I copied the files that the generator normally creates from an older project. Unfortunately I get the same error when I start the server. I tried commenting out the routes, but that didn't help. From the stack trace I think the issue is here:

gems/passbook-ruby-0.1.1/config/routes.rb:21:in `block in <top (required)>'

Sjors commented 11 years ago

I was able to solve this by changing the route notation style from Passbook::Passes#get_pkpass to passbook/passes#get_pkpass. Pull request coming as soon as I dealt with some other Rails 4 related issues.

Sjors commented 11 years ago

By the way I tried to write a routing spec for this fix, but I have no idea how to do that.

Sjors commented 11 years ago

I also changed attr_accessible to the new strong parameters convention. I don't know if that is backwards compatible or that you would need to use the strong parameters gem for older Rails versions.

That leaves one thing I don't know how to convert:

params.slice(*attr_accessible[:default].map(&:to_sym)).each do |attr, val|
  pass_pass.send :"#{attr}=", val
end

I'm not using that in my own project, so I can't test it and will leave it to someone else to solve...