I have a form in my app which is triggering the wrong controller action. Here's the rendered form:
<form id="edit_profile_1" class="simple_form profile windowed" method="post" enctype="multipart/form-data" action="/profiles/1" accept-charset="UTF-8">
<div style="margin:0;padding:0;display:inline">
<input type="hidden" value="✓" name="utf8">
<input type="hidden" value="put" name="_method">
<input type="hidden" value="..." name="authenticity_token">
</div>
....
</form>
So, pretty much a normal form. On my local environment this works fine, it triggers the profiles#update action. However, when deployed on Heroku for some reason this is triggering the profiles#show action, and therefore is not working.
What gives? Has anyone encountered this error before, and do you know how to fix it?
-EDIT- #Laas: Here's the production log:
2011-05-20T21:41:38+00:00 app[web.1]: Started GET "/account" for 98.201.59.6 at 2011-05-20 14:41:38 -0700
2011-05-20T21:41:40+00:00 heroku[router]: GET www.fourthenvironment.org/account dyno=web.1 queue=0 wait=0ms service=2212ms bytes=8672
2011-05-20T21:41:40+00:00 app[web.1]: Connected to NewRelic Service at collector-6.newrelic.com:80
2011-05-20T21:41:40+00:00 heroku[router]: GET www.fourthenvironment.org/javascripts/rails.js dyno=web.1 queue=0 wait=0ms service=2ms bytes=5176
2011-05-20T21:41:41+00:00 heroku[router]: GET www.fourthenvironment.org/javascripts/jquery.144.min.js dyno=web.1 queue=0 wait=0ms service=3ms bytes=78865
2011-05-20T21:41:42+00:00 heroku[router]: GET www.fourthenvironment.org/stylesheets/style.css dyno=web.1 queue=0 wait=0ms service=3ms bytes=63444
2011-05-20T21:41:47+00:00 heroku[router]: GET www.fourthenvironment.org/favicon.ico dyno=web.1 queue=0 wait=0ms service=4ms bytes=1672
2011-05-20T21:41:50+00:00 app[web.1]:
2011-05-20T21:41:50+00:00 app[web.1]:
2011-05-20T21:41:50+00:00 app[web.1]: Started POST "/profiles/1" for 98.201.59.6 at 2011-05-20 14:41:50 -0700
2011-05-20T21:41:50+00:00 heroku[router]: POST www.fourthenvironment.org/profiles/1 dyno=web.1 queue=0 wait=0ms service=102ms bytes=420
2011-05-20T21:41:50+00:00 app[web.1]: THIS SHOULD NOT BE TRIGGERED
2011-05-20T21:41:50+00:00 heroku[router]: GET www.fourthenvironment.org/profiles/1 dyno=web.1 queue=0 wait=0ms service=30ms bytes=414
2011-05-20T21:41:50+00:00 app[web.1]:
2011-05-20T21:41:50+00:00 app[web.1]:
2011-05-20T21:41:50+00:00 app[web.1]: Started GET "/account" for 98.201.59.6 at 2011-05-20 14:41:50 -0700
Note the "THIS SHOULD NOT BE TRIGGERED". Here's the controller:
class ProfilesController < ApplicationController
before_filter :authenticate_user!
def show
puts "THIS SHOULD NOT BE TRIGGERED"
redirect_to account_path
end
def edit
#profile = Profile.find(params[:id])
end
def update
puts "profiles#update"
#profile = Profile.find(params[:id])
if #profile.update_attributes(params[:profile])
redirect_to account_path, :notice => t('user.notice.updated')
else
render :action => 'edit'
end
end
end
It turns out the issue was related to the use of the SSL-Requirement Gem. For some reason if you send a request from an SSL page to a non-SSL page while using SSL-requirement it gets redirected. So, to fix, enable SSL-requirement on both ends of the request, and it will work. It looks like going from SSL to non SSL the gem only allows gets -- hence the bug. This looks to be irrelevant as of Rails 3.1 since a new SSL requirement functionality will be baked-in and the gem will not be required.
Many thanks to the Heroku staff for helping isolate this.
Seems to be identical to this problem routing-issues-with-multi-part-forms-on-heroku.
As it is only few days old, maybe it is not a coincidence and there's something awry with Heroku?
Why is the form tag hard coded? Use the form_tag helper
http://api.rubyonrails.org/classes/ActionView/Helpers/FormTagHelper.html
Related
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
Sorry to bother but I really don't know what else to try. I have pushed my rails application to heroku and during the last push everything went well except that one of the pages (projects#index) returns this error in Heroku:
We're sorry, but something went wrong.
If you are the application owner check the logs for more information.
The same doesn't occur in Cloud 9 when I run the server locally. The same page shows without issues.
Looking at previous answers, I've tried running:
heroku run rake db:migrate
I also tried re-pushing everything by running the following commands:
git push heroku
heroku pg:reset DATABASE
heroku run rails db:migrate
heroku run rails db:seed
heroku restart
Here are my heroku logs:
2016-11-09T18:48:22.095610+00:00 app[web.1]: * Min threads: 0, max threads: 16
2016-11-09T18:48:22.095627+00:00 app[web.1]: * Environment: production
2016-11-09T18:48:22.096004+00:00 app[web.1]: Use Ctrl-C to stop
2016-11-09T18:48:22.095780+00:00 app[web.1]: * Listening on tcp://0.0.0.0:3666
2016-11-09T18:48:22.259703+00:00 heroku[web.1]: State changed from starting to up
2016-11-09T18:48:24.502298+00:00 heroku[router]: at=info method=GET path="/projects" host=stark-falls-63733.herokuapp.com request_id=2c6f6731-bedc-4367-83f9-f40a87273fe5 fwd="86.44.57.230" dyno=web.1 connect=0ms service=1402ms status=500 bytes=1669
2016-11-09T18:48:24.790630+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=stark-falls-63733.herokuapp.com request_id=4dae94ac-b865-4514-b59b-074591a69d05 fwd="86.44.57.230" dyno=web.1 connect=0ms service=2ms status=200 bytes=143
2016-11-09T18:49:18.903562+00:00 heroku[api]: Starting process with command `rails db:migrate` by alessia.bass#yahoo.ie
2016-11-09T18:49:23.120484+00:00 heroku[run.7366]: Awaiting client
2016-11-09T18:49:23.143476+00:00 heroku[run.7366]: Starting process with command `rails db:migrate`
2016-11-09T18:49:23.302666+00:00 heroku[run.7366]: State changed from starting to up
2016-11-09T18:49:28.044047+00:00 heroku[run.7366]: State changed from up to complete
2016-11-09T18:49:28.029405+00:00 heroku[run.7366]: Process exited with status 0
2016-11-09T18:49:39.596513+00:00 heroku[api]: Starting process with command `rails db:seed` by alessia.bass#yahoo.ie
2016-11-09T18:49:44.198548+00:00 heroku[run.3484]: Awaiting client
2016-11-09T18:49:44.246315+00:00 heroku[run.3484]: Starting process with command `rails db:seed`
2016-11-09T18:49:44.304728+00:00 heroku[run.3484]: State changed from starting to up
2016-11-09T18:49:50.403853+00:00 heroku[run.3484]: State changed from up to complete
2016-11-09T18:49:50.393367+00:00 heroku[run.3484]: Process exited with status 0
2016-11-09T18:50:11.659495+00:00 heroku[router]: at=info method=GET path="/projects" host=stark-falls-63733.herokuapp.com request_id=73beb6fe-90c6-41c9-8f75-e8939fd7a4be fwd="86.44.57.230" dyno=web.1 connect=0ms service=109ms status=500 bytes=1669
2016-11-09T18:50:11.861324+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=stark-falls-63733.herokuapp.com request_id=694b31e7-b3df-4c00-85fa-d931d6f3ba11 fwd="86.44.57.230" dyno=web.1 connect=0ms service=3ms status=200 bytes=143
2016-11-09T18:50:13.257178+00:00 heroku[router]: at=info method=GET path="/projects" host=stark-falls-63733.herokuapp.com request_id=0c7878ec-0017-48a2-a53d-55126ca12a97 fwd="86.44.57.230" dyno=web.1 connect=0ms service=28ms status=500 bytes=1669
2016-11-09T18:50:13.422750+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=stark-falls-63733.herokuapp.com request_id=8c44d51f-ca89-487b-ae25-eb06ef04735e fwd="86.44.57.230" dyno=web.1 connect=0ms service=4ms status=200 bytes=143
2016-11-09T18:50:25.482365+00:00 heroku[web.1]: Restarting
2016-11-09T18:50:25.483959+00:00 heroku[web.1]: State changed from up to starting
2016-11-09T18:50:28.492311+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2016-11-09T18:50:29.151373+00:00 app[web.1]: - Gracefully stopping, waiting for requests to finish
2016-11-09T18:50:29.151850+00:00 app[web.1]: === puma shutdown: 2016-11-09 18:50:29 +0000 ===
2016-11-09T18:50:29.151889+00:00 app[web.1]: - Goodbye!
2016-11-09T18:50:29.152378+00:00 app[web.1]: Exiting
2016-11-09T18:50:29.358836+00:00 heroku[web.1]: Process exited with status 0
2016-11-09T18:50:29.841404+00:00 heroku[web.1]: Starting process with command `bin/rails server -p 22013 -e production`
2016-11-09T18:50:35.820996+00:00 app[web.1]: => Booting Puma
2016-11-09T18:50:35.821017+00:00 app[web.1]: => Rails 5.0.0.1 application starting in production on http://0.0.0.0:22013
2016-11-09T18:50:35.821018+00:00 app[web.1]: => Run `rails server -h` for more startup options
2016-11-09T18:50:37.033565+00:00 app[web.1]: Puma starting in single mode...
2016-11-09T18:50:37.033582+00:00 app[web.1]: * Version 3.4.0 (ruby 2.2.4-p230), codename: Owl Bowl Brawl
2016-11-09T18:50:37.033585+00:00 app[web.1]: * Min threads: 0, max threads: 16
2016-11-09T18:50:37.033617+00:00 app[web.1]: * Environment: production
2016-11-09T18:50:37.033865+00:00 app[web.1]: * Listening on tcp://0.0.0.0:22013
2016-11-09T18:50:37.034023+00:00 app[web.1]: Use Ctrl-C to stop
2016-11-09T18:50:37.177370+00:00 heroku[web.1]: State changed from starting to up
2016-11-09T18:50:37.930818+00:00 heroku[router]: at=info method=GET path="/projects" host=stark-falls-63733.herokuapp.com request_id=01420f22-76e1-4916-be34-e96e5db985df fwd="86.44.57.230" dyno=web.1 connect=0ms service=424ms status=500 bytes=1669
2016-11-09T18:50:38.121454+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=stark-falls-63733.herokuapp.com request_id=89d07228-0172-4809-8a43-241662cdfdcb fwd="86.44.57.230" dyno=web.1 connect=0ms service=4ms status=200 bytes=143
2016-11-09T18:52:12.082290+00:00 heroku[api]: Starting process with command `bundle exec rake db:migrate` by alessia.bass#yahoo.ie
2016-11-09T18:52:18.172017+00:00 heroku[run.6086]: State changed from starting to up
2016-11-09T18:52:18.336471+00:00 heroku[run.6086]: Awaiting client
2016-11-09T18:52:18.372809+00:00 heroku[run.6086]: Starting process with command `bundle exec rake db:migrate`
2016-11-09T18:52:23.522954+00:00 heroku[run.6086]: State changed from up to complete
2016-11-09T18:52:23.513862+00:00 heroku[run.6086]: Process exited with status 0
2016-11-09T18:52:30.397822+00:00 heroku[router]: at=info method=GET path="/projects" host=stark-falls-63733.herokuapp.com request_id=8a1dc1d5-1f5b-425b-8deb-c0d60dbe15bb fwd="86.44.57.230" dyno=web.1 connect=0ms service=61ms status=500 bytes=1669
2016-11-09T18:52:30.602701+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=stark-falls-63733.herokuapp.com request_id=6105f2be-9c60-4d35-8ff2-cc4fcf7b438f fwd="86.44.57.230" dyno=web.1 connect=1ms service=1ms status=200 bytes=143
2016-11-09T18:52:32.824633+00:00 heroku[router]: at=info method=GET path="/projects" host=stark-falls-63733.herokuapp.com request_id=074d3fc0-9ad1-4c50-9325-139d392b502b fwd="86.44.57.230" dyno=web.1 connect=0ms service=40ms status=500 bytes=1669
2016-11-09T18:52:32.985752+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=stark-falls-63733.herokuapp.com request_id=f13fa5bf-5f2f-48f7-92eb-ff09beb5919d fwd="86.44.57.230" dyno=web.1 connect=0ms service=8ms status=200 bytes=143
2016-11-09T18:52:37.881288+00:00 heroku[router]: at=info method=GET path="/users" host=stark-falls-63733.herokuapp.com request_id=e3d2067c-b093-41e0-9d6f-72a68f172edf fwd="86.44.57.230" dyno=web.1 connect=0ms service=50ms status=200 bytes=3208
2016-11-09T18:52:42.036223+00:00 heroku[router]: at=info method=GET path="/projects" host=stark-falls-63733.herokuapp.com request_id=df869638-2c3a-40ac-b0a7-ba4a3190cdd6 fwd="86.44.57.230" dyno=web.1 connect=0ms service=17ms status=500 bytes=1669
2016-11-09T18:53:01.489311+00:00 heroku[router]: at=info method=GET path="/projects" host=stark-falls-63733.herokuapp.com request_id=dd949ce7-bfb1-422b-81fd-8ebc02540e71 fwd="86.44.57.230" dyno=web.1 connect=1ms service=71ms status=500 bytes=1669
2016-11-09T19:13:01.823684+00:00 heroku[router]: at=info method=GET path="/projects" host=stark-falls-63733.herokuapp.com request_id=62e72010-b749-4a8e-9f5d-3ee2550e4eb5 fwd="86.44.57.230" dyno=web.1 connect=0ms service=21ms status=500 bytes=1669
2016-11-09T19:24:19.274988+00:00 heroku[api]: Starting process with command `bundle exec rake db:migrate` by alessia.bass#yahoo.ie
2016-11-09T19:24:25.388503+00:00 heroku[run.8672]: Awaiting client
2016-11-09T19:24:25.463637+00:00 heroku[run.8672]: Starting process with command `bundle exec rake db:migrate`
2016-11-09T19:24:25.535795+00:00 heroku[run.8672]: State changed from starting to up
2016-11-09T19:24:33.095488+00:00 heroku[run.8672]: Process exited with status 0
2016-11-09T19:24:33.081820+00:00 heroku[run.8672]: State changed from up to complete
2016-11-09T19:25:12.201241+00:00 heroku[router]: at=info method=GET path="/projects" host=stark-falls-63733.herokuapp.com request_id=529aeacd-e9b9-4b96-a2d7-34ddb5d3896e fwd="86.44.57.230" dyno=web.1 connect=0ms service=14ms status=500 bytes=1669
2016-11-09T19:25:12.469696+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=stark-falls-63733.herokuapp.com request_id=99e6fa84-47c2-4ae4-86cc-9f4e9f36ca16 fwd="86.44.57.230" dyno=web.1 connect=0ms service=2ms status=304 bytes=48
2016-11-09T19:28:30.885743+00:00 heroku[api]: Starting process with command `rails consoe` by alessia.bass#yahoo.ie
2016-11-09T19:28:35.368273+00:00 heroku[run.7002]: Awaiting client
2016-11-09T19:28:35.393535+00:00 heroku[run.7002]: Starting process with command `rails consoe`
2016-11-09T19:28:35.539374+00:00 heroku[run.7002]: State changed from starting to up
2016-11-09T19:28:38.853885+00:00 heroku[run.7002]: State changed from up to complete
2016-11-09T19:28:38.878693+00:00 heroku[run.7002]: Process exited with status 1
2016-11-09T19:28:46.270972+00:00 heroku[api]: Starting process with command `rails console` by alessia.bass#yahoo.ie
2016-11-09T19:28:51.734321+00:00 heroku[run.9640]: Awaiting client
2016-11-09T19:28:51.769438+00:00 heroku[run.9640]: Starting process with command `rails console`
2016-11-09T19:28:51.802682+00:00 heroku[run.9640]: State changed from starting to up
2016-11-09T19:29:03.378053+00:00 heroku[run.9640]: Process exited with status 0
2016-11-09T19:29:03.393812+00:00 heroku[run.9640]: State changed from up to complete
2016-11-09T19:29:16.843286+00:00 heroku[web.1]: Restarting
2016-11-09T19:29:16.843982+00:00 heroku[web.1]: State changed from up to starting
2016-11-09T19:29:20.220947+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2016-11-09T19:29:21.247977+00:00 app[web.1]: - Gracefully stopping, waiting for requests to finish
2016-11-09T19:29:21.248148+00:00 app[web.1]: === puma shutdown: 2016-11-09 19:29:21 +0000 ===
2016-11-09T19:29:21.248152+00:00 app[web.1]: - Goodbye!
2016-11-09T19:29:21.248232+00:00 app[web.1]: Exiting
2016-11-09T19:29:21.388099+00:00 heroku[web.1]: Process exited with status 0
2016-11-09T19:29:21.832713+00:00 heroku[web.1]: Starting process with command `bin/rails server -p 21042 -e production`
2016-11-09T19:29:25.892825+00:00 app[web.1]: => Booting Puma
2016-11-09T19:29:25.892864+00:00 app[web.1]: => Rails 5.0.0.1 application starting in production on http://0.0.0.0:21042
2016-11-09T19:29:25.892865+00:00 app[web.1]: => Run `rails server -h` for more startup options
2016-11-09T19:29:26.922809+00:00 heroku[web.1]: State changed from starting to up
2016-11-09T19:29:26.844730+00:00 app[web.1]: Puma starting in single mode...
2016-11-09T19:29:26.844748+00:00 app[web.1]: * Version 3.4.0 (ruby 2.2.4-p230), codename: Owl Bowl Brawl
2016-11-09T19:29:26.844749+00:00 app[web.1]: * Min threads: 0, max threads: 16
2016-11-09T19:29:26.844750+00:00 app[web.1]: * Environment: production
2016-11-09T19:29:26.844827+00:00 app[web.1]: * Listening on tcp://0.0.0.0:21042
2016-11-09T19:29:26.845007+00:00 app[web.1]: Use Ctrl-C to stop
2016-11-09T19:29:28.618363+00:00 heroku[router]: at=info method=GET path="/projects" host=stark-falls-63733.herokuapp.com request_id=ae553309-c165-4526-b443-fd098df71c47 fwd="86.44.57.230" dyno=web.1 connect=1ms service=139ms status=500 bytes=1669
2016-11-09T19:29:28.754190+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=stark-falls-63733.herokuapp.com request_id=453d6e7f-b4e8-4337-9340-84cb8dcaa95f fwd="86.44.57.230" dyno=web.1 connect=1ms service=3ms status=200 bytes=143
2016-11-09T19:29:28.910252+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=stark-falls-63733.herokuapp.com request_id=79a6c43e-1ef3-4467-a60e-2c83d7ae0e83 fwd="86.44.57.230" dyno=web.1 connect=1ms service=2ms status=200 bytes=143
2016-11-09T19:29:30.017146+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=stark-falls-63733.herokuapp.com request_id=0dcba4a6-2113-437c-acb3-4383f16dd191 fwd="104.131.194.174" dyno=web.1 connect=0ms service=1ms status=200 bytes=143
This is my index view:
<% provide(:title, 'All Projects') %>
<h1>All Projects</h1>
<table>
<tbody>
<tr>
<td>
<div class="dropdown">
<button class="btn btn-default dropdown-toggle" type="button"
data-toggle="dropdown">Filter by Team<span class="caret"></span></button>
<ul class="dropdown-menu">
<% Team.all.each do |team| %>
<li>
<%= link_to team.tName, projects_path(team: team.tName), class: "link" %>
</li>
<li class="<%= 'active' if params[:team] == team.tName %>">
<% end %>
</ul>
</div>
</td>
</tr>
<tr>
<td>
<div>
<button type="button" class="btn btn-default"><%= link_to "Remove Team Filters", projects_path, class: "link" %></button>
</div>
</td>
</tr>
</tbody>
</table>
<ul class="users">
<%= render 'projects/projectindex' %>
</ul>
And the partial rendered is:
<% #projects.each do |project| %>
<h2><%= params[:team] %></h2>
<% if #projects.count == 0 %>
<h2>There are no projects currently in this category</h2>
<% end %>
<li>
Title: <%= project.title %><br>
Team: <%= project.team.tName%><br>
Description: <%= project.description %><br>
Status:<%= project.status %><br>
Type: <%= project.p_type %><br>
Updated: <%= time_ago_in_words(project.updated_at) %> ago.
</li>
<% end %>
Any idea how I can fix the issue?
Thank you in advance for your time.
So... as everything was working locally I continued with my work by adding a new model, similar to the project one that I had already created. I pushed everything to heroku and following the same steps as before:
git push heroku
heroku pg:reset DATABASE
heroku run rails db:migrate
heroku run rails db:seed
heroku restart
When I went into the heroku site, the error on the project index page was no longer occurring. I didn't touch anything on any of the project pages as the new model is independent from the project one... I really don't know why!
Thanks to #Lucas Costa for trying to help and for anybody that has taken the time to read my question.
i have deployed an app to heroku(finance tracker under "ROR developer course" from udemy.com). The login button works fine but when i click on the signup button, it gives me this error
We're sorry, but something went wrong.
If you are the application owner check the logs for more information.
I have ran heroku run rake db:migrate successfully.
I used devise gem for authentication.
Pls any idea someone??....thanks
Edit
From log:
2016-10-26T17:46:19.965045+00:00 heroku[router]: at=info method=GET path="/users/sign_up" host=johnuzoma-finance-tracker.herokuapp.com request_id=9b928dfe-66be-47b5-933b-3d5b6cf3a899 fwd="197.210.25.210" dyno=web.1 connect=0ms service=19ms status=500 bytes=1754
2016-10-26T17:46:19.950321+00:00 app[web.1]: Started GET "/users/sign_up" for 197.210.25.210 at 2016-10-26 17:46:19 +0000
2016-10-26T17:46:19.955368+00:00 app[web.1]: Processing by User::RegistrationsController#new as HTML
2016-10-26T17:46:19.957892+00:00 app[web.1]: Completed 500 Internal Server Error in 2ms (ActiveRecord: 0.0ms)
2016-10-26T17:46:19.958887+00:00 app[web.1]:
2016-10-26T17:46:19.958889+00:00 app[web.1]: NoMethodError (undefined method `for' for #<Devise::ParameterSanitizer:0x007f782dff6408>):
2016-10-26T17:46:19.958890+00:00 app[web.1]: app/controllers/user/registrations_controller.rb:7:in `configure_permitted_parameters'
2016-10-26T17:46:19.958891+00:00 app[web.1]:
2016-10-26T17:46:19.958892+00:00 app[web.1]:
2016-10-26T17:46:20.651597+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=johnuzoma-finance-tracker.herokuapp.com request_id=8d875ac1-de78-47 68-9cd0-a653afd2318b fwd="197.210.25.210" dyno=web.1 connect=0ms service=6ms status=304 bytes=133
RegistrationsController code
class User::RegistrationsController < Devise::RegistrationsController
before_filter :configure_permitted_parameters
protected
def configure_permitted_parameters
devise_parameter_sanitizer.for(:sign_up).push(:first_name, :last_name)
devise_parameter_sanitizer.for(:account_update).push(:first_name, :last_name)
end
end
So the first thing you should do is go to the Heroku admin panel for your app and look through the log file. You should find a stack trace (should look like an error followed by a bunch of method calls and line numbers). Another option is for you to remotely access the app server, go to you Heroku app directory on your computer and run (assuming you have Heroku CLI installed)
heroku run bash
then navigate to your log directory and run
tail -f <replace_with_log_file_name>
(log file should be production.log or develop.log) and that will show you a real time stream of the log activity, so just go recreate the bug and see what happens.
Replace these lines
def configure_permitted_parameters
devise_parameter_sanitizer.for(:sign_up).push(:first_name, :last_name)
devise_parameter_sanitizer.for(:account_update).push(:first_name, :last_name)
end
With these lines
def configure_permitted_parameters
devise_parameter_sanitizer.permit(:sign_up, keys: [:first_name, :last_name])
devise_parameter_sanitizer.permit(:account_update, keys: [:first_name, :last_name])
end
What happened is the gem devise that you are using changed its API in version for so the syntax you are were using is no longer valid. I am assuming that at some point in time you did a bundle update or something that inadvertently upgraded you gem
If you are facing this much difficulty in determining error through Heroku logs one more thing you can try is you can see error on the browser itself and to do that in your production.rb file (which you will find in config/environments directory) change:
config.action_controller.consider_all_requests_local = false
To:
config.action_controller.consider_all_requests_local = true
Now deploy your app again on Heroku and you are good to go.
I have a rails4 app deployed on heroku and using cloudfront as CDN.
Everything works fine in development. In production only the things in the app/assets are served properly, the images in the public folder can't be found.
What should I do to make the public folder assets work? I'd like to serve them from CDN as well if possible, but I'm open to any working solution
Current settings:
production.rb
config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present? #enabled by heroku default settings
config.assets.compile = false
config.assets.digest = true
config.action_controller.asset_host = 'mycode.cloudfront.net'
config.font_assets.origin = '*'
gemfile
# I'm NOT using asset_sync gem
gem 'font_assets', '~> 0.1.12' #this is needed to make googlefonts work
gem 'rails_12factor', '~> 0.0.3', group :production
UPDATE:
working heroku logs
2016-01-25T19:00:24.624690+00:00 heroku[router]: at=info method=GET path="/500.html" host=appfaskyn.herokuapp.com request_id=d1a637be-b539-429a-9fcd-5f4d0025b562 fwd="50.250.214.91" dyno=web.1 connect=2ms service=5ms status=304 bytes=48
2016-01-25T19:00:24.794605+00:00 heroku[router]: at=info method=GET path="/thirdlogo.png" host=appfaskyn.herokuapp.com request_id=41b8aa45-8e70-43ef-af53-b4e0ad44ec8b fwd="50.250.214.91" dyno=web.1 connect=0ms service=4ms status=304 bytes=48
UPDATE2:
Realized that it works w/ certain routes.
So if I hit app/dsfd then it finds the pic with path="/dsfd"
but if I hit app/users/2 (user does not exist anymore, so should be the same page does not exist error) then path="/users/2" can't find the pic.
log if found:
2016-01-29T18:56:14.377420+00:00 heroku[router]: at=info method=GET path="/dsfd" host=www.faskyn.com request_id=76e1c73d-dd22-446f-89b4-096dcbae6f6c fwd="64.245.0.218" dyno=web.1 connect=0ms service=23ms status=404 bytes=840
2016-01-29T18:56:14.320423+00:00 app[web.1]: source=rack-timeout id=76e1c73d-dd22-446f-89b4-096dcbae6f6c wait=0ms timeout=20000ms state=ready
2016-01-29T18:56:14.320609+00:00 app[web.1]: source=rack-timeout id=76e1c73d-dd22-446f-89b4-096dcbae6f6c wait=0ms timeout=20000ms service=1ms state=active
2016-01-29T18:56:14.324730+00:00 app[web.1]: Started GET "/dsfd" for 64.245.0.218 at 2016-01-29 18:56:14 +0000
2016-01-29T18:56:14.331095+00:00 app[web.1]:
2016-01-29T18:56:14.331099+00:00 app[web.1]: ActionController::RoutingError (No route matches [GET] "/fddf"):
2016-01-29T18:56:14.331100+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/actionpack-4.2.4/lib/action_dispa
logs if not found:
Processing by UsersController#show as PNG
2016-01-29T18:49:20.952915+00:00 app[web.1]: Parameters: {"id"=>"thirdlogo"}
2016-01-29T18:49:20.959096+00:00 app[web.1]: User Load (3.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 ORDER BY "users"."id" ASC LIMIT 1 [["id", 1]]
2016-01-29T18:49:20.963937+00:00 app[web.1]: Completed 404 Not Found in 11ms (ActiveRecord: 4.7ms)
2016-01-29T18:49:20.985358+00:00 heroku[router]: at=info method=GET path="/users/thirdlogo.png" host=www.faskyn.com request_id=e913ee09-3837-4da6-8e7f-f3eebc15de00 fwd="64.245.0.218" dyno=web.1 connect=0ms service=30ms status=404 bytes=840
My app runs fine locally, but when I push to Heroku, in Firefox it says "The page isn't redirecting properly" (i.e. a 302 error).
Running heroku logs results in a bunch of requests like this:
2015-06-02T21:30:26.556750+00:00 heroku[router]: at=info method=GET path="/" host=www.mydomainname.com request_id=a0cb3aa2-af7c-431a-9cc4-a237e551ae0a fwd="173.27.229.45" dyno=web.1 connect=2ms service=13ms status=302 bytes=499
2015-06-02T21:30:27.761039+00:00 heroku[router]: at=info method=GET path="/" host=www.mydomainname.com request_id=32026d7d-2167-4058-8ef6-8ebd15af7460 fwd="173.27.229.45" dyno=web.1 connect=2ms service=12ms status=302 bytes=499
2015-06-02T21:30:27.914344+00:00 heroku[router]: at=info method=GET path="/" host=www.mydomainname.com request_id=2087a90c-fd56-4d14-b630-9c92fda30c80 fwd="173.27.229.45" dyno=web.1 connect=1ms service=15ms status=302 bytes=499
When I run the "Network" option under Firefox's Developer section, it continuously shows that it is alternating between the domain with and without www. For example:
www.domain.com
domain.com
www.domain.com
domain.com
etc.
I am using a custom domain name but have it set up exactly how my other apps that are working are set up, so I don't think it is a DNS issue as far as how the setup goes. Also, when I visit the "myappname.herokuapp.com" URL, it immediately redirects to heroku.com for some reason. Not sure why. I ran the "Production Check" and it passes the "DNS configuration" section.
I realize that I have not provided a bunch of information here (not sure what else to provide), but any ideas on what I could look into next?
EDIT: Today it is saying this prior to the redirect code posted earlier:
2015-06-03T14:38:14.651296+00:00 heroku[web.2]: State changed from up to down
2015-06-03T14:38:17.135688+00:00 heroku[web.2]: Stopping all processes with SIGTERM
2015-06-03T14:38:17.774095+00:00 app[web.2]: [2015-06-03 14:38:17] FATAL SignalException: SIGTERM
2015-06-03T14:38:17.774101+00:00 app[web.2]: /app/vendor/ruby-2.1.5/lib/ruby/2.1.0/webrick/server.rb:170:in `select'
2015-06-03T14:38:17.774103+00:00 app[web.2]: /app/vendor/ruby-2.1.5/lib/ruby/2.1.0/webrick/server.rb:170:in `block in start'
2015-06-03T14:38:17.774104+00:00 app[web.2]: /app/vendor/ruby-2.1.5/lib/ruby/2.1.0/webrick/server.rb:32:in `start'
2015-06-03T14:38:17.774105+00:00 app[web.2]: /app/vendor/ruby-2.1.5/lib/ruby/2.1.0/webrick/server.rb:160:in `start'
2015-06-03T14:38:17.774106+00:00 app[web.2]: /app/vendor/bundle/ruby/2.1.0/gems/rack-1.6.0/lib/rack/handler/webrick.rb:35:in `run'
2015-06-03T14:38:17.774108+00:00 app[web.2]: /app/vendor/bundle/ruby/2.1.0/gems/rack-1.6.0/lib/rack/server.rb:286:in `start'
2015-06-03T14:38:17.774109+00:00 app[web.2]: /app/vendor/bundle/ruby/2.1.0/gems/railties-4.2.0/lib/rails/commands/server.rb:80:in `start'
2015-06-03T14:38:17.774110+00:00 app[web.2]: /app/vendor/bundle/ruby/2.1.0/gems/railties-4.2.0/lib/rails/commands/commands_tasks.rb:80:in `block in server'
2015-06-03T14:38:17.774111+00:00 app[web.2]: /app/vendor/bundle/ruby/2.1.0/gems/railties-4.2.0/lib/rails/commands/commands_tasks.rb:75:in `tap'
2015-06-03T14:38:17.774113+00:00 app[web.2]: /app/vendor/bundle/ruby/2.1.0/gems/railties-4.2.0/lib/rails/commands/commands_tasks.rb:75:in `server'
2015-06-03T14:38:17.774114+00:00 app[web.2]: /app/vendor/bundle/ruby/2.1.0/gems/railties-4.2.0/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
2015-06-03T14:38:17.774115+00:00 app[web.2]: /app/vendor/bundle/ruby/2.1.0/gems/railties-4.2.0/lib/rails/commands.rb:17:in `<top (required)>'
2015-06-03T14:38:17.774117+00:00 app[web.2]: bin/rails:4:in `require'
2015-06-03T14:38:17.774118+00:00 app[web.2]: bin/rails:4:in `<main>'
2015-06-03T14:38:17.774147+00:00 app[web.2]: [2015-06-03 14:38:17] INFO WEBrick::HTTPServer#start done.
2015-06-03T14:38:17.774124+00:00 app[web.2]: [2015-06-03 14:38:17] INFO going to shutdown ...
2015-06-03T14:38:17.828035+00:00 app[web.2]: => Booting WEBrick
2015-06-03T14:38:17.828041+00:00 app[web.2]: => Rails 4.2.0 application starting in production on http://0.0.0.0:4223
2015-06-03T14:38:17.828043+00:00 app[web.2]: => Run `rails server -h` for more startup options
2015-06-03T14:38:17.828045+00:00 app[web.2]: => Ctrl-C to shutdown server
2015-06-03T14:38:17.828046+00:00 app[web.2]: Exiting
2015-06-03T14:38:18.624457+00:00 heroku[web.2]: Process exited with status 143
EDIT 2: I re-cloned the repository into a different directory and then ran heroku create, git push heroku master, and then heroku run rake db:migrate. I did this to eliminate any possible DNS issues. The log now says:
2015-06-03T15:55:51.082260+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=lit-inlet-1933.herokuapp.com request_id=2cd494b9-8f93-4270-b8db-e1dda9a6ab4a fwd="173.27.229.45" dyno= connect= service= status=503 bytes=
2015-06-03T15:55:51.274766+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=lit-inlet-1933.herokuapp.com request_id=78128ada-cb90-4580-8102-be756ec7b7cc fwd="173.27.229.45" dyno= connect= service= status=503 bytes=
2015-06-03T15:55:53.861456+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=lit-inlet-1933.herokuapp.com request_id=6d89785d-1b00-4b40-8984-15dbbe5e994f fwd="173.27.229.45" dyno= connect= service= status=503 bytes=
This shows 2 crashes to the root url "/" and 2 crashes on /favicon.ico. Based on the favicon.ico, I removed any favicons from the root page as a test. Now the app is behaving similarly to the earlier one: It immediately redirects to heroku.com instead of loading the page and the logs says:
2015-06-03T16:00:42.804253+00:00 heroku[web.1]: State changed from crashed to starting
2015-06-03T16:00:48.568268+00:00 heroku[web.1]: Starting process with command `bin/rails server -p 25258 -e production`
2015-06-03T16:00:57.769255+00:00 app[web.1]: [2015-06-03 16:00:57] INFO WEBrick 1.3.1
2015-06-03T16:00:57.769284+00:00 app[web.1]: [2015-06-03 16:00:57] INFO ruby 2.1.5 (2014-11-13) [x86_64-linux]
2015-06-03T16:00:57.769643+00:00 app[web.1]: [2015-06-03 16:00:57] INFO WEBrick::HTTPServer#start: pid=3 port=25258
2015-06-03T16:00:58.321124+00:00 heroku[web.1]: State changed from starting to up
2015-06-03T16:01:00.754258+00:00 heroku[router]: at=info method=GET path="/" host=lit-inlet-1933.herokuapp.com request_id=8664d409-5542-4bee-914d-00639c08c2d0 fwd="173.27.229.45" dyno=web.1 connect=1ms service=174ms status=302 bytes=501
The root URL is very simple. There is a welcome_controller:
class WelcomeController < ApplicationController
skip_before_filter :authenticate_user!, only: :index
def index
end
end
and the view is:
<div class="jumbotron">
<h1> Task Clash</h1>
<p>A ridiculously simple and easy-to-use CRM/Time Tracking tool aimed at small businesses!</p>
<p><%= link_to "Create Account", new_account_path, class: "btn btn-primary btn-lg" %></p>
</div>
Any help would be greatly appreciated!
EDIT 3: I added rails_12factor to my Gemfile and now get this:
2015-06-03T19:37:48.713189+00:00 heroku[router]: at=info method=GET path="/" host=www.taskclash.com request_id=c0dfd7ac-233c-4be9-a155-57b66f9a84cb fwd="173.27.229.45" dyno=web.1 connect=0ms service=12ms status=302 bytes=435
2015-06-03T19:37:48.700898+00:00 app[web.1]: Started GET "/" for 173.27.229.45 at 2015-06-03 19:37:48 +0000
2015-06-03T19:37:48.710826+00:00 app[web.1]: Account Load (1.4ms) SELECT "public"."accounts".* FROM "public"."accounts" WHERE "public"."accounts"."subdomain" = $1 LIMIT 1 [["subdomain", "www"]]
2015-06-03T19:37:48.711577+00:00 app[web.1]: Filter chain halted as :load_schema rendered or redirected
2015-06-03T19:37:48.711704+00:00 app[web.1]: Completed 302 Found in 8ms (ActiveRecord: 6.5ms)
2015-06-03T19:37:48.703333+00:00 app[web.1]: Processing by TasksController#index as HTML
2015-06-03T19:37:48.711291+00:00 app[web.1]: Redirected to https://taskclash.com/
Check if there's a production migration pending. Run from the terminal this command:
$ heroku run rake db:migrate
If there are no migrations pending, post more lines of the logs.