thoughtbot / griddler

Simplify receiving email in Rails (deprecated)
http://griddler.io/
MIT License
1.38k stars 199 forks source link

Routing problems with and without route helper #81

Closed joshsmith closed 11 years ago

joshsmith commented 11 years ago

When I use post '/email_processor' => 'griddler/emails#create', I get the following error:

Invalid route name, already in use: 'email_processor'  (ArgumentError)
You may have defined two routes with the same name using the `:as` option, or you may be overriding a route already defined by a resource with the same naming. For the latter, you can restrict the routes created with `resources` as explained here:
http://guides.rubyonrails.org/routing.html#restricting-the-routes-created

When I use the route helper mount_griddler without any arguments, I get this error:

undefined local variable or method `mount_griddler' for #<ActionDispatch::Routing::Mapper:0x007f95a6d78f50> (NameError)

Clearly not desired behavior, but not really sure why this might be happening. Any thoughts?

theycallmeswift commented 11 years ago

Can you share your Gemfile and and routes file?

jlerpscher commented 11 years ago

Hi,

Same issue, my Gemfile :

source 'https://rubygems.org'

gem 'rails', '4.0.0'
gem 'haml'
gem 'sass-rails', '~> 4.0.0'
gem 'bootstrap-sass', :git => 'git://github.com/thomas-mcdonald/bootstrap-sass.git', :branch => '3'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.0.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 1.2'
gem 'griddler'

group :development do
  gem 'sqlite3'  
end

group :development, :test do
  gem 'rspec-rails', '~> 2.0'
end

group :test do
  gem 'factory_girl'
end

My routes.rb file :

Myapp::Application.routes.draw do

  mount_griddler
  match '(:locale)', to: 'posts#index', via: [:get, :post]

  scope ':locale', :constraints => { :locale => /fr/ } do

    resources :posts

    root to: 'posts#index'
  end

end

Cheers, Julien.

calebhearth commented 11 years ago

The mount_griddler helper is not in the released version of Griddler.

@jlerpscher are you also seeing the Invalid route name error with the post '/email_processor' => 'griddler/emails#create' line?

@JoshSmith it sounds like you have another route defined called email_processor. Check your config/routes.rb for that name, or as @theycallmeswift suggested you can post your routes and we'll take a look.

jlerpscher commented 11 years ago

Thank you for your reply,

If I use this line, I have the following error:

Invalid route name, already in use: 'email_processor'  (ArgumentError)
You may have defined two routes with the same name using the `:as` option, or you may be overriding a route already defined by a resource with the same naming. For the latter, you can restrict the routes created with `resources` as explained here
calebhearth commented 11 years ago

Can you paste the output of rake routes | grep email_processor, or let us know if there isn't any output?

calebhearth commented 11 years ago

I'm also wondering if this is some sort of double-require issue. What happens if the griddler change is the last line in routes.rb?

jlerpscher commented 11 years ago

Here is the output of rake routes (before trying to add the griddler route):

email_processor POST /email_processor(.:format) griddler/emails#create

Putting the route at the bottom of routes.rb doesn't change anything.

calebhearth commented 11 years ago

Ah, so the problem is that, in the released version of Griddler, we had already defined the route.

If /email_processor works for you, there is no need to add it to routes.rb. If not, please use the github version of Griddler until we cut a release: gem 'griddler', github: 'thoughtbot/griddler' and you can defined it wherever you'd like:

post '/your/favorite/path' => 'griddler/emails#create', as: :email_processor

Sorry about that, totally our fault.

jlerpscher commented 11 years ago

No problem, I will use the Github version until next release!

Thanks for this awesome gem :)

calebhearth commented 11 years ago

I just pushed a new version. Let us know if you run into any more issues, and thanks for working with us to troubleshoot.