Started GET "/node_modules/src/formSubmitDispatcher.ts" for ::1 at
2022-10-09 18:10:14 -0500 18:10:14 web.1 | 18:10:14 web.1 |
ActionController::RoutingError (No route matches [GET]
"/node_modules/src/formSubmitDispatcher.ts")
This is the error I see in the rails server. I do not see any error on the actual webpage an everything keeps working expect for the new feature I'm adding. It's a slideover form for adding comments to a blog using MRUJS/Cable Car. I have found the formSubmitDispatcher.ts file in the directory tree, but is located at /node_modules/mrujs/src/formSubmitDispatcher.ts. For some reason the path is wrong. Is there a way to fix this? This is not code that I wrote myself. It was generated as part of installing MRUJS. I'm happy to provide any relevant information, but as of right now I have no idea what that might be.
Related
I never wrote any complex regular expression before, and what I need seems to be (at least) a bit complicated.
I need a Regex to find matches for the following:
Here below show the logs for this i need regexp plesase help Thanking you in advance
Started GET \"/\" for 1x2.x6.1xx.2x at 2016-10-20 11:04:00 +0200
Processing by WelcomeController#index as HTML
Current user: anonymous
Redirected to http://example.pro.local/login?back_url=http%xx%xx%2Fexample.pro.local%2F
Filter chain halted as :check_if_login_required rendered or redirected
Completed 302 Found in 3.4ms (ActiveRecord: 1.9ms)"
Extracting information from unstructured logs with regex is tedious and brittle.
Instead it is preferable to make the application output logs in a structured format (as suggested by #ndn).
Consider using lograge and/or logstasher in your Rails application to output structured logs.
Continuing with my Rails Library Management App, I learnt about scaffolds and thought that it would give me ample framework to re-work upon. The thing is, that although scaffolds are being generated and everything, they aren't working properly. Rather, they aren't working at all.
When I access to http://localhost/[controller-name], It shoots up a webpage that says Listing [controller-name] all fine. But when i click on new button or navigate to http://localhost/[controller-name]/new, the server crashes without an error.
P.S.
While trying things, I noticed that although,
$ rails generate scaffold person name:string identity:integer DOB:date
works just fine,
$ rails generate scaffold student name:string id_number:integer class:integer section:string issued:date returned:date fine:integer reissued:date
doesn't?
P.P.S.
The real problem is, accessing the action "student#new" does not only NOT work, but also crashes my server (yeah no exiting WEBrick). All I can provide are the messages that appear at the end:
Started GET "/assets/students.css?body=1" for 127.0.0.1 at 2015-08-05 12:20:19 +0530
Started GET "/assets/scaffolds.css?body=1" for 127.0.0.1 at 2015-08-05 12:20:19 +0530
Started GET "/assets/application.css?body=1" for 127.0.0.1 at 2015-08-05 12:20:19 +0530
Started GET "/students/new" for 127.0.0.1 at 2015-08-05 12:20:21 +0530
Processing by StudentsController#new as HTML
class is a keyword in Ruby, so using that as a column name isn't a great idea. On this line:
$ rails generate scaffold student name:string id_number:integer class:integer section:string issued:date returned:date fine:integer reissued:date
change class:integer to kind:integer and it should work.
I have a Ruby on Rails app that works fine locally with a sqlite3 database and can save and retrieve records without issue.
When deployed to Heroku at http://moviedata.herokuapp.com/ using a postgresql database, records are not saving even though it looks like the logs say they are. Records read from the db fine and data is displayed as expected.
The tailed logs for adding a record are:
2012-08-21T19:51:31+00:00 app[web.1]:
2012-08-21T19:51:31+00:00 app[web.1]:
2012-08-21T19:51:31+00:00 app[web.1]: Started POST "/" for 50.53.6.156 at 2012-08-21 19:51:31 +0000
2012-08-21T19:51:31+00:00 app[web.1]: Parameters: {"utf8"=>"✓", "authenticity_token"=>"+BYQLzhrfDkUVW8UaHikHpmtGHxpeQ/yF4VByHh9m1I=", "movie"=>{"title"=>"The Running Man", "description"=>"A documentary about a public execution game show.", "year"=>"1987", "genre"=>"science fiction"}, "commit"=>"Create Movie"}
2012-08-21T19:51:31+00:00 app[web.1]: Processing by MoviesController#index as HTML
2012-08-21T19:51:31+00:00 app[web.1]: Rendered movies/index.html.erb within layouts/application (5.1ms)
2012-08-21T19:51:31+00:00 app[web.1]: Completed 200 OK in 9ms (Views: 6.7ms | ActiveRecord: 0.9ms)
2012-08-21T19:51:31+00:00 heroku[router]: POST moviedata.herokuapp.com/ dyno=web.1 queue=0 wait=0ms service=17ms status=200 bytes=3479
The 'heroku pg' command shows the same number of rows (11) on the postgres database after a record is added.
This is a simple app I built to learn Rails and the Heroku platform. To reproduce this, just visit http://moviedata.herokuapp.com/ and click "New Movie", enter some junk data in the form, and hit "create movie". The record should be saved and show up in the list on the front page, but it doesn't.
Is there perhaps something I have to turn on, configure, or activate in order to be able to write to the postgres database? Seems very strange to me that it could be read from but not written to. Any better way to troubleshoot than the logs?
Locally I'm using Ruby 1.9.3, Rails, 3.2.8, PostgreSQL 9.1.5, SQLite 3.7.9, Heroku Toolbelt 2.30.3.
Edit/Update: I switched the local version to use psql. It also experiences the same problem where records are not saved. With the user set to log_statement='all' The log in at /var/log/postgresql/posgresql-9.1.main.log shows lots of selects, but when the record add is attempted, the log shows the database never being hit.
Foreman shows the data being posted, like so:
22:38:03 web.1 | Started POST "/" for 127.0.0.1 at 2012-08-21 22:38:02 -0700
22:38:03 web.1 | Processing by MoviesController#index as HTML
22:38:03 web.1 | Parameters: {"utf8"=>"✓", "authenticity_token"=>"0AyxRbwl/Kgi05uI1KX8uxVUJjx9ylAA1ltdWgmunm4=", "movie"=>{"title"=>"Army of Darkness", "description"=>"A man fights the living dead using a boomstick.", "year"=>"1997", "genre"=>"horror"}, "commit"=>"Create Movie"}
22:38:03 web.1 | Movie Load (0.8ms) SELECT "movies".* FROM "movies" ORDER BY title
22:38:03 web.1 | Rendered movies/index.html.erb within layouts/application (14.9ms)
A failed commit does sound like a great explanation. I'm not yet sure how to check whether the driver is set to commit or to see how/when a commit might have failed.
This is a very simple application, with no load balancing or complex configuration and most of the code was generated by the 'generate scaffold' command, but it's entirely possible that there's some constraint that's being violated somewhere before the db is ever hit. Perhaps there's a way to crank the Foreman (or Rails) log level up to 11? I also tried using thin instead and scoured the log files in the log/ folder and didn't find anything other than what's logged above.
This sounds a lot like a transaction issue, where you aren't COMMITting your transactions after you do work, so the changes are lost. If your SQLite driver defaults to COMMITting transactions that're closed without an explicit COMMIT or rollback, and your Pg driver defaults to ROLLBACK, you'd get the behaviour described. The same will happen if the SQLite defaults to autocomitting each statement by default, and the Pg driver driver defaults to opening a transaction.
This is one of the many good reasons to use the same local database for testing as you're going to deploy to when you want to go live.
If you were on a normal Pg instance I'd tell you to enable log_statement = 'all' in postgresql.conf, reload Pg, and watch the logs. You can't do that on Heroku, but you do have access to the Pg logs with heroku logs --ps postgres. Try running ALTER USER my_heroku_user SET log_statement = 'all';, re-testing, and examining the logs.
Alternately, install Pg locally.
Other less likely possibilities that come to mind:
You're using long-running SERIALIZABLE transactions for reads, so their snapshot never gets updated. Pretty unlikely.
Permissions on database objects are causing INSERTs, UPDATEs, etc to fail, and your app is ignoring the resulting errors. Again, unlikely.
You have DO INSTEAD rules that don't do what you expect, or BEFORE triggers that return NULL, thus silently turning operations into no-ops. Seems unlikely if you're testing with SQLite.
You're writing to a different DB than you're reading from. Not impossible in setups that're attempting to read from a cluster of hot standbys, etc.
When I go to a bogus url like:
/posts/99999999
On my local machine, I see:
ActiveRecord::RecordNotFound in Posts#show
Showing /Users/patrick/rails/my_app/app/views/posts/show.html.haml where line #1 raised:
Couldn't find Post with ID=99999
... The log shows:
Rendered posts/show.html.haml within layouts/application (29.6ms)
Completed in 423ms
ActionView::Template::Error (Couldn't find Post with ID=99999)
--- However, when I do this in production, I get the public/500.html error page, not 404... I'm kind of confused because in development mode, the browser shows ActiveRecord::RecordNotFound (which should mean 404, yes?) but the log shows ActionView::Template::Error-- not one mention of ActiveRecord::RecordNotFound.
So, ultimately, my question is, how can I make this a 404 not a 500? And-- why is it a 500?
From what I have seen, Rails should automatically make an ActiveRecord::RecordNotFound render the 404.html page... The problem I discovered was I am using the gem decent_exposure, and because of it's nature of lazy loading, it causes the error to happen in the view rather than the controller, and therefore Rails doesn't know to render the 404 page because it shows up as an actual ActionView::Template::Error...
Just add a ! to the find_by_column method.
Example:
#post = Post.find_by_id!(params[:id])
Then, a RecordNotFound exception is thrown.
there is a scaffold created Story... and in the create action, there is
#story = Story.new(params[:story])
i was curious as to what is in params... so i want to dump out params... but there is no view associated with the create action... is there a way to dump out its content? is there a way to dump out the POST variables in of my code too? (to see what's going on in the lower level)
The easiest thing to do is just dump params out to the log:
Rails.logger.info("PARAMS: #{params.inspect}")
If you're in development mode, just look in your development.log and that line will be there.
The params scope is a combination of URL/FORM (GET/POST) fields, and it will be printed out in the log as part of the normal output processing, so you might not need your own dumping of it - any development or production log contains the params dump at the top of the log line, e.g.
Processing Clients::ClientsController#show (for x.x.x. at 2009-05-24 00:34:26) [GET]
Parameters: {"id"=>"303", "user_id"=>"2"}
Now I know Rails more, you can also simply use a
p params
in your code and look at the console's output (the log shown on the console)
If you're on a Mac, Spike is a great little app the analyses log files and will let you inspect params for requests, amongst other things.
Using Fiddler on Windows, it is shown
the HTTP line #1 is:
POST /stories HTTP/1.1
this is the POST content:
authenticity_token=62iw%2BrsxlCFsbnxsS7FXKRn6CcvJfjottrsBPlM5lZo%3D&story%5Bname%5D=Google+Main+Site&story%5Blink%5D=www.google.com&commit=Create
listed in a table:
authenticity_token 62iw+rsxlCFsbnxsS7FXKRn6CcvJfjottrsBPlM5lZo=
story[name] Google Main Site
story[link] www.google.com
commit Create
and the server log is:
Parameters: {"commit"=>"Create", "story"=>{"name"=>"Google Main Site", "link"=>"www.google.com"}, "authenticity_token"=>"62iw+rsxlCFsbnxsS7FXKRn6CcvJfjottrsBPlM5lZo="}
You don't need to anything except look in your logs (they live in /log). Unless you're fiddling with something, the logging of parameters is turned on by default in all logs.
Processing PostsController#create (for 127.0.0.1 at 2009-05-24 13:03:24) [POST]
Parameters: {"commit"=>"Create", "authenticity_token"=>"2G6BKOs8xNAaXiToVf4r1ko8QZzP9QAomi2PHVQC5Oc=", "story"=>{"something"=>"asdfafd"}}
Parameters lists all parameters, and the hash following "story" is the equivalent of params[:story] (everything comes to the server as strings, and Rails turns it into a HashWithIndifferentAccess so that you can access it with a symbol).
If you're on a *NIX system (including OS X) open a new terminal window/tab and type the following command:
tail -f log/development.log
You'll get a constant stream of requests coming in -- including params -- and the resulting DB actions. Invaluable for development/debugging, IMO.