I am new to Ruby and Rails in general and am following this series
https://gorails.com/episodes/rails-for-beginners-part-38-deploying-to-heroku
I have this weird issue where is everything seems to work fine except connecting my app with
Twitter Api.
I did everything to connect successfully but nothing seems working!
I added the website link to Twitter developer callbacks urls which are
https://jadwlh.herokuapp.com/
along with
https://jadwlh.herokuapp.com/auth/twitter/callback
I added both
API_KEY
and
API_SECRET
to Config Vars.
I even changed SECRET_KEY_BASE in Config Vars
to the one provided in the credentials file in my app!
Even though tried everything, still got this message shown in the image below when I try to
connect my app with Twitter Api
routes.rb file
# For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html
Rails.application.routes.draw do
#GET /about
get "about", to: "about#index"
get "password", to: "passwords#edit", as: :edit_password
patch "password", to: "passwords#update"
get "sign_up", to: "registrations#new"
post "sign_up", to: "registrations#create"
delete "logout", to: "sessions#destroy"
get "sign_in", to: "sessions#new"
post "sign_in", to: "sessions#create"
get "password/reset", to: "password_resets#new"
post "password/reset", to: "password_resets#create"
get "password/reset/edit", to: "password_resets#edit"
patch "password/reset/edit", to: "password_resets#update"
get "/auth/twitter/callback", to: "omniauth_callbacks#twitter"
resources :twitter_accounts
resources :tweets
# get "/", to: "main#index"
root to: "main#index"
end
Application logs
2021-05-31T06:15:04.415968+00:00 app[web.1]: [13f44544-8fd2-4348-8b08-1191ad53716b]
2021-05-31T06:15:04.418156+00:00 heroku[router]: at=info method=HEAD path="/auth/failure?message=session_expired&strategy=twitter" host=jadwlh.herokuapp.com request_id=13f44544-8fd2-4348-8b08-1191ad53716b fwd="217.182.175.162" dyno=web.1 connect=0ms service=3ms status=404 bytes=180 protocol=https
2021-05-31T06:15:31.243002+00:00 app[web.1]: I, [2021-05-31T06:15:31.242901 #4] INFO -- : [c5f8ff8c-58fa-439d-a9f3-e08047bc5aa8] Started POST "/auth/twitter" for 46.152.103.96 at 2021-05-31 06:15:31 +0000
2021-05-31T06:15:31.243645+00:00 app[web.1]: D, [2021-05-31T06:15:31.243583 #4] DEBUG -- omniauth: (twitter) Request phase initiated.
2021-05-31T06:15:31.388564+00:00 app[web.1]: E, [2021-05-31T06:15:31.388453 #4] ERROR -- omniauth: (twitter) Authentication failure! 400 Bad Request: OAuth::Unauthorized, 400 Bad Request
2021-05-31T06:15:31.390962+00:00 heroku[router]: at=info method=POST path="/auth/twitter" host=jadwlh.herokuapp.com request_id=c5f8ff8c-58fa-439d-a9f3-e08047bc5aa8 fwd="46.152.103.96" dyno=web.1 connect=1ms service=150ms status=302 bytes=834 protocol=https
2021-05-31T06:15:31.574904+00:00 heroku[router]: at=info method=GET path="/auth/failure?message=400+Bad+Request&strategy=twitter" host=jadwlh.herokuapp.com request_id=3adfd6f0-58b9-47c3-ab04-017161a56e18 fwd="46.152.103.96" dyno=web.1 connect=1ms service=6ms status=404 bytes=1902 protocol=https
2021-05-31T06:15:31.571195+00:00 app[web.1]: I, [2021-05-31T06:15:31.571067 #4] INFO -- : [3adfd6f0-58b9-47c3-ab04-017161a56e18] Started GET "/auth/failure?message=400+Bad+Request&strategy=twitter" for 46.152.103.96 at 2021-05-31 06:15:31 +0000
2021-05-31T06:15:31.572790+00:00 app[web.1]: F, [2021-05-31T06:15:31.572717 #4] FATAL -- : [3adfd6f0-58b9-47c3-ab04-017161a56e18]
2021-05-31T06:15:31.572791+00:00 app[web.1]: [3adfd6f0-58b9-47c3-ab04-017161a56e18] ActionController::RoutingError (No route matches [GET] "/auth/failure"):
2021-05-31T06:15:31.572792+00:00 app[web.1]: [3adfd6f0-58b9-47c3-ab04-017161a56e18]
Thank you: )
I found the solution.
It just was copying master.key and replace it as it says below!
heroku config:set RAILS_MASTER_KEY="copy and paste here config/master.key "
How to get rails master.key after upgrading to rails 5.2
Related
I am using Rails 7.0.2.3 and my website is active for two weeks now. Devise gem for authentication.
Recently (today) one of my colleagues noticed a problem. When clicking on sign_out he is receiving 404 not found. He is using Safari on Iphone, I tested the same on Chrome on Samsung, and on browsers on Desktop PC
This is my View
<%= link_to 'Одјави се', destroy_admin_session_path, data: { turbo_method: :delete, turbo_confirm: 'Одјави се?' }, class: 'nav-link' %>
These are the logs I am catching from heroku.
2022-04-16T16:23:02.349221+00:00 heroku[router]: at=info method=GET path="/admins/sign_out" host=www.mywebsite request_id=********* fwd="**.**.**" dyno=web.1 connect=0ms service=4ms status=404 bytes=20331 protocol=https
2022-04-16T16:23:02.347534+00:00 app[web.1]: I, [2022-04-16T16:23:02.347453 #4] INFO -- : [*********] Started GET "/admins/sign_out" for **.**.**.** at 2022-04-16 16:23:02 +0000
2022-04-16T16:23:02.348459+00:00 app[web.1]: F, [2022-04-16T16:23:02.348405 #4] FATAL -- : [*********]
2022-04-16T16:23:02.348460+00:00 app[web.1]: [*********] ActionController::RoutingError (No route matches [GET] "/admins/sign_out"):
2022-04-16T16:23:02.348460+00:00 app[web.1]: [*********]
I will point out that this was not a problem until today, probably yesterday if we haven't noticed. How can something like this affect from sudden? I am able to sign_out from Desktop using Brave browser, both on normal mode and on Incognito.
Any advise could be useful.
Thanks
Hi I'm fairly new to coding and I'm building a rails/react habit builder app. Everything works fine when running on local server. However I've switched the database over to postgres and deployed to heroku, and nearly everything works except for a create action in one of my of controllers.
def create
current_user.identities.build(identity_params)
if identity.save
render json: IdentitySerializer.new(identity).serialized_json
else
render json: { error: identity.errors.messages }, status: 422
end
end
here is my current_method
def current_user
#current_user ||= User.find(session[:user_id]) if session[:user_id]
end
here is the error in my heroku log
2020-11-16T16:14:03.944788+00:00 heroku[router]: at=info method=GET path="/api/v1/categories" host=atomic-habits-app.herokuapp.com request_id=94543abb-1522-464f-9c8e-44e7bc6f765b fwd="68.199.184.23" dyno=web.1 connect=1ms service=103ms status=304 bytes=445 protocol=https
2020-11-16T16:14:16.585828+00:00 app[web.1]: I, [2020-11-16T16:14:16.585700 #8] INFO -- : [f2c1ff5a-c6b8-4304-89a4-7174caed6c0b] Started POST "/api/v1/identities" for 68.199.184.23 at 2020-11-16 16:14:16 +0000
2020-11-16T16:14:16.587457+00:00 app[web.1]: I, [2020-11-16T16:14:16.587389 #8] INFO -- : [f2c1ff5a-c6b8-4304-89a4-7174caed6c0b] Processing by Api::V1::IdentitiesController#create as HTML
2020-11-16T16:14:16.587570+00:00 app[web.1]: I, [2020-11-16T16:14:16.587508 #8] INFO -- : [f2c1ff5a-c6b8-4304-89a4-7174caed6c0b] Parameters: {"identity"=>{"category_id"=>"1", "name"=>"test", "description"=>"test", "standard"=>"7"}}
2020-11-16T16:14:16.590058+00:00 app[web.1]: I, [2020-11-16T16:14:16.589975 #8] INFO -- : [f2c1ff5a-c6b8-4304-89a4-7174caed6c0b] Completed 500 Internal Server Error in 2ms (Allocations: 570)
2020-11-16T16:14:16.591415+00:00 app[web.1]: F, [2020-11-16T16:14:16.591334 #8] FATAL -- : [f2c1ff5a-c6b8-4304-89a4-7174caed6c0b]
2020-11-16T16:14:16.591416+00:00 app[web.1]: [f2c1ff5a-c6b8-4304-89a4-7174caed6c0b] NoMethodError (undefined method `identities' for nil:NilClass):
2020-11-16T16:14:16.591417+00:00 app[web.1]: [f2c1ff5a-c6b8-4304-89a4-7174caed6c0b]
2020-11-16T16:14:16.591417+00:00 app[web.1]: [f2c1ff5a-c6b8-4304-89a4-7174caed6c0b] app/controllers/api/v1/identities_controller.rb:17:in `create'
2020-11-16T16:14:16.592938+00:00 heroku[router]: at=info method=POST path="/api/v1/identities" host=atomic-habits-app.herokuapp.com request_id=f2c1ff5a-c6b8-4304-89a4-7174caed6c0b fwd="68.199.184.23" dyno=web.1 connect=0ms service=9ms status=500 bytes=1841 protocol=https
And again, this create action works perfectly fine when I run it on my local server. And in production the create method works for signing up a user and creating a session. And when creating a session I console.log the response from the sessions controller which includes
render json: {
logged_in: true,
current: current_user,
user: #user
}
And the current user object gets logged to the console upon login.
So im not sure if the issue is relationship related between identity and users (user has many identities), or if there is an issue relying on sessions in production? I've really made no progress debugging this. Any ideas or advice is very much appreciated. Sorry if I left out any necessary code. Here are links to repo and heroku
https://atomic-habits-app.herokuapp.com/
https://github.com/mattkuras/Habit-Helper
edit**
Thank you Eyeslandic for this response it seems to be working.
"Rails.application.config.session_store :cookie_store, key: '_habit-helper', domain: 'localhost:3000' could be the problem, referencing port 3000 especially"
I changed port 3000 to :all in my config/initializers/session_store.rb. The cookie wasnt properly being set
So I'm using the RSpotify to have users approve our app and then redirect to our site. The problem is that when Spotify redirects it is including a query string. This is throwing it off and it thinks that the URI is not an approved source.
Everything was working until I put my site up on heroku.
Here is the error:
+00:00 app[web.1]: I, [2020-02-17T12:09:24.460751 #4] INFO -- omniauth: (spotify) Request phase initiated.
2020-02-17T12:09:24.464829+00:00 heroku[router]: at=info method=GET path="/auth/spotify" host=www.themixtapeproj.com request_id=cf73be87-9844-4b18-ba0b-518e4046676a fwd="47.17.47.4" dyno=web.1 connect=1ms service=4ms status=302 bytes=1463 protocol=http
2020-02-17T12:09:24.663083+00:00 heroku[router]: at=info method=GET path="/auth/spotify/callback?code=AQArRuRXYD_gebJVlU1Ljht_4XDFr_1dAAqlI-20Tq5504JFdP92MpRIDoNFVvBpS4xPPAqrdAJlooCTZA3yLPeUFKk5W1SE9KkLFsDp--1tIm2Vt2Y6_jrNWmDsBvWvBkuSlBbXaBW5gti8sbIHlMCHXt8MDP82l2BTduVDgjStbSuFt8SoWo8BLeYT8pc68LUs7eFqoJoww-ywkc0gLz1V7tzpEkOkn6I8N7-LRTr9cXQt_kJfQdnpsbiQ0KSn2g&state=2d5bbf3deccf88d92d68f5022475522564622cfc77104794" host=www.themixtapeproj.com request_id=f8ef1adc-0693-4ab5-bf63-f23b63b3ee1b fwd="47.17.47.4" dyno=web.1 connect=1ms service=50ms status=302 bytes=769 protocol=http
2020-02-17T12:09:24.612879+00:00 app[web.1]: I, [2020-02-17T12:09:24.612791 #4] INFO -- : [f8ef1adc-0693-4ab5-bf63-f23b63b3ee1b] Started GET "/auth/spotify/callback?code=AQArRuRXYD_gebJVlU1Ljht_4XDFr_1dAAqlI-20Tq5504JFdP92MpRIDoNFVvBpS4xPPAqrdAJlooCTZA3yLPeUFKk5W1SE9KkLFsDp--1tIm2Vt2Y6_jrNWmDsBvWvBkuSlBbXaBW5gti8sbIHlMCHXt8MDP82l2BTduVDgjStbSuFt8SoWo8BLeYT8pc68LUs7eFqoJoww-ywkc0gLz1V7tzpEkOkn6I8N7-LRTr9cXQt_kJfQdnpsbiQ0KSn2g&state=2d5bbf3deccf88d92d68f5022475522564622cfc77104794" for 47.17.47.4 at 2020-02-17 12:09:24 +0000
2020-02-17T12:09:24.613242+00:00 app[web.1]: I, [2020-02-17T12:09:24.613191 #4] INFO -- omniauth: (spotify) Callback phase initiated.
2020-02-17T12:09:24.659971+00:00 app[web.1]: E, [2020-02-17T12:09:24.659789 #4] ERROR -- omniauth: (spotify) Authentication failure! invalid_credentials: OAuth2::Error, invalid_grant: Invalid redirect URI
2020-02-17T12:09:24.659978+00:00 app[web.1]: {"error":"invalid_grant","error_description":"Invalid redirect URI"}
2020-02-17T12:09:24.765658+00:00 app[web.1]: I, [2020-02-17T12:09:24.765530 #4] INFO -- : [bdbf5819-3907-42ba-9d02-6c32137425b5] Started GET "/auth/failure?message=invalid_credentials&origin=http%3A%2F%2Fwww.themixtapeproj.com%2Fmixtapes%2F4&strategy=spotify" for 47.17.47.4 at 2020-02-17 12:09:24 +0000
2020-02-17T12:09:24.766489+00:00 app[web.1]: F, [2020-02-17T12:09:24.766404 #4] FATAL -- : [bdbf5819-3907-42ba-9d02-6c32137425b5]
From what I understand it is the query string that is throwing it off. Since I have approved http://www.themixtapeproj.com/auth/spotify/callback
So what do I have to do to get this working?
EDIT: here is the authorize part (appears before the above error):
2020-02-17T15:41:52.150535+00:00 heroku[router]: at=info method=GET path="/auth/spotify" host=www.themixtapeproj.com request_id=2092bd50-787f-4f4f-a3a5-47e8ed29c171 fwd="100.38.116.113" dyno=web.1 connect=0ms service=15ms status=302 bytes=1451 protocol=http
2020-02-17T15:41:52.032671+00:00 heroku[router]: at=info method=GET path="/auth/spotify" host=www.themixtapeproj.com request_id=43b76294-4e0b-4137-9c40-ef0d132d97ed fwd="100.38.116.113" dyno=web.1 connect=13ms service=66ms status=302 bytes=1457 protocol=http
2020-02-17T15:41:52.005375+00:00 app[web.1]: I, [2020-02-17T15:41:52.005256 #4] INFO -- : [43b76294-4e0b-4137-9c40-ef0d132d97ed] Started GET "/auth/spotify" for 100.38.116.113 at 2020-02-17 15:41:52 +0000
2020-02-17T15:41:52.005965+00:00 app[web.1]: I, [2020-02-17T15:41:52.005846 #4] INFO -- omniauth: (spotify) Request phase initiated.
2020-02-17T15:41:52.140507+00:00 app[web.1]: I, [2020-02-17T15:41:52.140388 #4] INFO -- : [2092bd50-787f-4f4f-a3a5-47e8ed29c171] Started GET "/auth/spotify" for 100.38.116.113 at 2020-02-17 15:41:52 +0000 ```
Rails.application.config.middleware.use OmniAuth::Builder do
spotify_key = ENV['SPOTIFY_KEY']
spotify_secret = ENV['SPOTIFY_SECRET']
provider :spotify, spotify_key, spotify_secret, scope: 'playlist-modify-public'
end
def spotify
spotify_user = RSpotify::User.new(request.env['omniauth.auth'])
session[:spotify_user] = spotify_user.to_hash
redirect_to spotify_landing_path
end
I don't know where else to turn with this: I have spent many hours on my project, a recruiting events website for college students, but have reached quite the impasse.
In short, I plodded along in localhost - adding components like Devise; Omniauth authentication via providers Facebook, LinkedIn, and Google - building a website I was proud of along the way. Everything appeared to be working just fine, but once I pushed to 'heroku master' things started breaking big time.
I think the issues are most likely in or around:I have an Authentication model to keep track of a single user's authentication providers, alongside the User model (where all the oauth code is kept).
Without further ado, here is my app's heroku domain and my code:
http://lit-everglades-7633.herokuapp.com/
https://gist.github.com/mecampbellsoup/6357855
The things breaking which I suspect are related:
'heroku run rake db:seed' following 'pg:reset' & 'rake db:migrate'... instead of seeding with the contents of the seed file itself, a single blank Event and Company are created; more on this below
the routing and action relating to the omniauth request seems to be working just fine, according to the heroku logs (below) but no user nor authentication is actually created:
when, after resetting postgres db, I try to run 'heroku run rake db:create' or 'db:setup' I am whined at as follows:
☁ duke_recruits [master] heroku run rake db:setup
Running rake db:setup attached to terminal... up, run.5886
FATAL: permission denied for database "postgres"
DETAIL: User does not have CONNECT privilege.
also, 'heroku run rake db:seed' appears to be doing its thing, but then my db only has 1 empty Event and 1 empty Company:
☁ duke_recruits [master] heroku run rake db:seed
Running rake db:seed attached to terminal... up, run.1767
☁ duke_recruits [master] heroku run rails c
Running rails c attached to terminal... up, run.6135
Event.allLoading production environment (Rails 4.0.0)
irb(main):001:0> Event.all
=> #ActiveRecord::Relation [#Event id: 1, title: nil, location: nil, description: nil, date: nil, end_date: nil, company_id: nil, created_at: "2013-08-27 19:30:06", updated_at: "2013-08-27 19:30:06"]
irb(main):002:0> Company.all
=> #ActiveRecord::Relation [#Company id: 1, name: nil, description: nil, website: nil, logo: nil, created_at: "2013-08-27 19:30:06", updated_at: "2013-08-27 19:30:06"]
Logs (upon opening the app on heroku and trying google authentication):
2013-08-27T19:49:18.701285+00:00 app[web.1]: Started GET "/" for 68.175.76.48 at 2013-08-27 19:49:18 +0000
2013-08-27T19:49:18.701019+00:00 app[web.1]: => Rails 4.0.0 application starting in production on http://0.0.0.0:49710
2013-08-27T19:49:18.701019+00:00 app[web.1]: => Ctrl-C to shutdown server
2013-08-27T19:49:18.701019+00:00 app[web.1]: => Booting WEBrick
2013-08-27T19:49:18.701019+00:00 app[web.1]: => Run `rails server -h` for more startup options
2013-08-27T19:49:18.701019+00:00 app[web.1]: Started GET "/" for 68.175.76.48 at 2013-08-27 19:49:18 +0000
2013-08-27T19:49:19.131115+00:00 heroku[router]: at=info method=GET path=/ host=lit-everglades-7633.herokuapp.com fwd="68.175.76.48" dyno=web.1 connect=2ms service=442ms status=304 bytes=0
2013-08-27T19:49:19.221284+00:00 heroku[router]: at=info method=GET path=/assets/application-b44a43097f814ac98347f6802323e25f.js host=lit-everglades-7633.herokuapp.com fwd="68.175.76.48" dyno=web.1 connect=1ms service=12ms status=304 bytes=0
2013-08-27T19:49:49.440894+00:00 app[web.1]: Started GET "/" for 68.175.76.48 at 2013-08-27 19:49:49 +0000
2013-08-27T19:49:49.440894+00:00 app[web.1]: Started GET "/" for 68.175.76.48 at 2013-08-27 19:49:49 +0000
2013-08-27T19:49:49.515520+00:00 heroku[router]: at=info method=GET path=/ host=lit-everglades-7633.herokuapp.com fwd="68.175.76.48" dyno=web.1 connect=2ms service=80ms status=304 bytes=0
2013-08-27T19:50:48.534099+00:00 app[web.1]: Started GET "/" for 68.175.76.48 at 2013-08-27 19:50:48 +0000
2013-08-27T19:50:48.534099+00:00 app[web.1]: Started GET "/" for 68.175.76.48 at 2013-08-27 19:50:48 +0000
2013-08-27T19:50:48.575279+00:00 heroku[router]: at=info method=GET path=/ host=lit-everglades-7633.herokuapp.com fwd="68.175.76.48" dyno=web.1 connect=1ms service=51ms status=304 bytes=0
2013-08-27T19:50:52.293922+00:00 app[web.1]: Started GET "/users/sign_up" for 68.175.76.48 at 2013-08-27 19:50:52 +0000
2013-08-27T19:50:52.293922+00:00 app[web.1]: Started GET "/users/sign_up" for 68.175.76.48 at 2013-08-27 19:50:52 +0000
2013-08-27T19:50:52.591752+00:00 heroku[router]: at=info method=GET path=/users/sign_up host=lit-everglades-7633.herokuapp.com fwd="68.175.76.48" dyno=web.1 connect=1ms service=307ms status=304 bytes=0
2013-08-27T19:51:00.368352+00:00 app[web.1]: Started GET "/users/auth/google_oauth2" for 68.175.76.48 at 2013-08-27 19:51:00 +0000
2013-08-27T19:51:00.368352+00:00 app[web.1]: Started GET "/users/auth/google_oauth2" for 68.175.76.48 at 2013-08-27 19:51:00 +0000
2013-08-27T19:51:00.368926+00:00 app[web.1]: I, [2013-08-27T19:51:00.368823 #2] INFO -- omniauth: (google_oauth2) Request phase initiated.
2013-08-27T19:51:00.392262+00:00 heroku[router]: at=info method=GET path=/users/auth/google_oauth2 host=lit-everglades-7633.herokuapp.com fwd="68.175.76.48" dyno=web.1 connect=3ms service=33ms status=302 bytes=469
2013-08-27T19:51:00.715597+00:00 app[web.1]: Started GET "/users/auth/google_oauth2" for 68.175.76.48 at 2013-08-27 19:51:00 +0000
2013-08-27T19:51:00.715597+00:00 app[web.1]: Started GET "/users/auth/google_oauth2" for 68.175.76.48 at 2013-08-27 19:51:00 +0000
2013-08-27T19:51:00.716822+00:00 app[web.1]: I, [2013-08-27T19:51:00.716706 #2] INFO -- omniauth: (google_oauth2) Request phase initiated.
2013-08-27T19:51:00.997866+00:00 app[web.1]: Started GET "/users/auth/google_oauth2/callback?state=40ecfd10739cb874b5c461fc00cfd72ec4fcb694ef3a6878&code=4/D_(omitted_for_security)_GBlmiYhY(partially_omitted)E9yth.QpxI3jdcGpYYshQV0ieZDAoQOqyCgQI" for 68.175.76.48 at 2013-08-27 19:51:00 +0000
2013-08-27T19:51:00.997866+00:00 app[web.1]: Started GET "/users/auth/google_oauth2/callback?state=10739cb874b5c461fc00cfd72ec4fcb694ef3a6878&code=4/D_GBlmiYhY1rCvgdgE9yth.QpxI3jdcGpYYshQV0ieZDAoQOqyCgQI" for 68.175.76.48 at 2013-08-27 19:51:00 +0000
2013-08-27T19:51:00.998508+00:00 app[web.1]: I, [2013-08-27T19:51:00.998379 #2] INFO -- omniauth: (google_oauth2) Callback phase initiated.
2013-08-27T19:51:02.188467+00:00 app[web.1]: Started GET "/users/sign_up" for 68.175.76.48 at 2013-08-27 19:51:02 +0000
2013-08-27T19:51:02.188467+00:00 app[web.1]: Started GET "/users/sign_up" for 68.175.76.48 at 2013-08-27 19:51:02 +0000
2013-08-27T19:51:02.234644+00:00 heroku[router]: at=info method=GET path=/users/sign_up host=lit-everglades-7633.herokuapp.com fwd="68.175.76.48" dyno=web.1 connect=9ms service=52ms status=304 bytes=0
Please let me know what questions you have for me and if I can clarify anything at all. I really appreciate your time & help SO!
After a pg:reset, you can run the create command, but it usually gives you output like:
slkdjfs0dslkd already exists
So then you'll know that your database is created and ready to be used. Before you can seed though make sure you migrate. Just the standard heroku way
heroku run rake db:migrate
Then seed as normal
heroku run rake db:seed
I'm writing an app in Rails (v3.0.5), which I'm deploying to Heroku.
When I visit http://localhost:3000/places/new in my development environment, I'm taken to the appropriate page (the form for creating a new place). Everything works as expected (I can create new places).
When I try to visit the corresponding page (http://example.heroku.com/places/new) in my Heroku production environment, I'm routed back to the home page for my app.
The contents of my routes.db file:
ExampleSite::Application.routes.draw do
resources :users
resources :sessions, :only => [:new, :create, :destroy]
resources :places
root :to => 'pages#home'
match '/contact', :to -> 'pages#contact'
match '/about', :to -> 'pages#about'
match '/signin', :to -> 'sessions#new'
match '/signout', :to -> 'sessions#destroy'
end
What might be a cause for the discrepancy between development and production?
Note: the only actions I've built out so far in my 'places' controller are 'new' and 'create' (both of which perform as expected in the development environment). Not sure that should be relevant, but keep it in mind. Also, all of the 'users' actions and routes seem to be working as expected in both development and production.
EDIT: As noted in the comment below, /places/new is an authentication-protected page, but in both cases I'm trying this while logged in. Also, when I do try to access /places/new in my production environment while not logged in, the appropriate redirect (to my /signin page) works as expected.
My Heroku log from an attempt at getting /place/new:
2011-05-12T23:37:30+00:00 app[web.1]: Started GET "/places/new" for 74.87.126.82 at Thu May 12 16:37:30 -0700 2011
2011-05-12T23:37:30+00:00 app[web.1]: Processing by PlacesController#new as HTML
2011-05-12T23:37:30+00:00 app[web.1]: Redirected to http://example.heroku.com/
2011-05-12T23:37:30+00:00 app[web.1]: Completed 302 Found in 4ms
2011-05-12T23:37:30+00:00 heroku[router]: GET example.heroku.com/places/new dyno=web.1 queue=0 wait=0ms service=9ms bytes=631
2011-05-12T23:37:30+00:00 app[web.1]:
2011-05-12T23:37:30+00:00 app[web.1]:
2011-05-12T23:37:30+00:00 app[web.1]: Started GET "/" for 74.87.126.82 at Thu May 12 16:37:30 -0700 2011
2011-05-12T23:37:30+00:00 app[web.1]: Processing by PagesController#home as HTML
2011-05-12T23:37:30+00:00 app[web.1]: Rendered layouts/_header.html.erb (4.3ms)
2011-05-12T23:37:30+00:00 app[web.1]: Rendered pages/home.html.erb within layouts/application (5.7ms)
2011-05-12T23:37:30+00:00 app[web.1]: Completed 200 OK in 7ms (Views: 3.5ms | ActiveRecord: 5.8ms)
2011-05-12T23:37:30+00:00 heroku[router]: GET example.heroku.com/ dyno=web.1 queue=0 wait=0ms service=14ms bytes=2357
As it turns out, I had a second (forgotten, since I changed the scope of 'users') authentication condition which checked for admin-level status. THAT condition redirected to the home page if the current user was not an admin.
The test user I created in my development environment IS an admin (since I created that user before switching the scope), while the test user I created in the production environment IS NOT an admin (hence the redirect).
Thanks all for your help! While this mistake was an oversight, your suggestions taught me about a few new diagnostic tools I hadn't thought to use.