I'm trying to create a very simple Hello, world program in RoR, but when I go to view the url http://localhost:3000/say/hello I'm getting the error message No route matches: "say/hello"
I started with: rails generate controller Say hello goodbye
which lists route get "say/hello"
Also: I'm having this problem which is probably related. When I go to write some basic html in one of the files that is clearly listed as existing I get this:
I write this:
~/work/demo$ /app/views/say/hello.html.erb
Get this error message in return:
bash: /app/views/say/hello.html.erb: No such file or directory
What's going on here? I'm getting these instructions straight from Agile Development with Rails and it's so simple.
With the details you've given I'm not sure why your route can't be found.
However, I believe the reason you're experiencing the no such file or directory error is because you're typing /app/views/say/hello.html.erb. Try removing the leading slash, so that it reads app/views/say/hello.html.erb. Bash appears to be parsing the former path as an absolute path, instead of a path relative to your current working directory.
What is this command?
~/work/demo$ /app/views/say/hello.html.erb
you should be using your web browser: http://localhost:3000/say/hello
Related
Please advise. This SQLPlus call:
SQL > #dba_files_all
...is not working.
SP2-0310: unable to open file "dba_files_all.sql"
How can I resolve the error?
You need to provide the path of the file as string.
Put the path in double quotes and it will work.
For example:
#"C:\Users\Arpan Saini\Zions R2\Reports Statements and Notices\Patch\08312017_Patch_16.2.3.17\DB Scripts\snsp.sql";
I encountered this error when attempting to execute a file in the same folder as the calling function. In my example, this process:
Was executed in SQL Developer;
Has been a long-standing part of my system (moving a setup file with some settings and variable names through various folders; those folder names include the feature IDs and a short description);
Has worked fine in the past;
Did not require any pathing in my case because the files were in the same folder;
Failed on the most recent attempt with the error above (SP2-0310).
The issue in my situation was that the folder name in which it failed included a character (#) that was valid for a Windows file name, but confusing to SQL Developer.
1.Use absolute path:
/u01/app/oaracle/test.sql
2.Check the path to see if script exists:
ls -l /u01/app/oaracle/test.sql
Note that
SQL> #some_file.sql
means that sql app you are using will look for that using "absolute path" so if you want to use "relative path" use following format [add ?]
SQL> #?some_file.sql
else, use "full path" with first command.
All the answers so far imply that absolute paths are required. That aren't. Relative paths in sql is pretty universal in sql tools. Sometimes, you have to configure a lost default configuration such as in the case of SQLDeveloper as explained in this answer:
https://stackoverflow.com/a/24003529/442968
I just run into same error when I was trying to unlock oe schema.
While reading the error, I realized that when I run the following line:
>SQL #?/demo/schema/order_entry/oe_main.sql
The error returned a completely different path
SP2-0310: unable to open file "C:/app/USER/product/18.0.0/dbhomeXE/demo/schema/order_entry/oe_main.sql"
Thus I copied my sql file to the path specified by the error and everything worked. I recommend that you do the same. Check the path in the error and adjust accordingly.
Use absolute path or run sqlplus command from a shell/dos that points to the path of the script. Also, to use a masterscript, refer to subscripts with ##.
verify that your file has an extension .sql not .sql.txt
I have a requirement to handle an application that is POSTing XML to a server and port. Unfortunately it is not possible for me to specify a path from this application and no way for me to change it.
So in Wireshark I can see it POSTing to
http://10.0.126.11:8082 <--- note the lack of trailing slash
If I set a test POST as follows in wfetch, I can route it just fine in grails. The following is what shows in Wireshare:
http://10.0.126.11:8082/ <--- trailing slash
I have the grails setup to route setup for the root path "/" in the UrlMappings and have setup the grails.app.context = "/" in the Config.groovy. Note that things just go badly if these are set to empty string.
Is there a way to go a step above the root path and respond to anything on the server:port? Can Grails respond to a request without a path?
This is the situation I'm trying to handle when recreating with wfetch (note that there is no path):
I have an mp3 in <my root directory>/app/assets/sound. I want to be able to access this file from an html file, with the following:
<audio src="/assets/sound/mysong.mp3">
However the html5 audio player does not show up, and when I try to go to this link directly in my browser, I get an error:
Routing Error
No route matches [GET] "/assets/sound/mysong.mp3"
I've tried many variations on the URL, adding the sound directory to my config.assets.path, and setting config.serve_static_assets = true in my production.rb, and nothing is working. What is the fix for this?
Note that I don't require a high-performance server for this web page, so I don't want to handle static assets through Apache or anything else complicated. I just want a simple method for Rails to find a given file and return it.
One easy way to fix this would be to move the file to public/sound/mysong.mp3 and reference it by src="/sound/mysong.mp3". That should work fine, but does not use the asset pipeline.
I am trying to execute phantom.js module from rails. So far I've successfully installed the binary and the path for phantomjs seems to be working fine.
However when I try to run it from a rails app using backtick (for example: phantomjs rasterize.js http://google.com 1.jpg), it says No such file or directory.
I think the reason is it can't find the path for rasterize.js
I tried putting the rasterize.js file in #{Rails.root}, inside public folder, inside controller folder but nothing works.
How can I solve this problem?
====
UPDATE: To clarify, i'm posting which code works inside my controller and which doesn't.
def create
'phantomjs'
end
<= Above code doesn't spit out path error, and when I send a request from the browser, phantomjs process does get invoked, resulting in opening up the console in the server side.
def create
'phantomjs rasterize.js'
end
<= This doesn't work, and it spits out error saying "No such file or directory", and that's why I think it has to do with rails not being able to find rasterize.js's path. I tried putting rasterize.js inside public folder, inside controllers folder, and inside the main directory: #{Rails.root}, but it's always the same.
Interesting... I've been trying all kinds of combinations and finally ran into a case that works, and it's not what I expected:
%x("/usr/local/bin/phantomjs /Users/e/Dropbox/Projects/rails/screenshots/rasterize.js http://google.com app/assets/images/2709.jpg")
<= This doesn't work.
system("/usr/local/bin/phantomjs /Users/e/Dropbox/Projects/rails/screenshots/rasterize.js http://google.com app/assets/images/2709.jpg")
<= This works.
I thought these all work internally the same, except for return values? Maybe I was wrong?
Let say your command is cmd.It is good to know that %(cmd) and exec(cmd), change the process you are on so if you are in rails and changed the directory it will exit. On the other hand `cmd` and system(cmd) will let you continute working.
I learned that from this blog. http://blog.jayfields.com/2006/06/ruby-kernel-system-exec-and-x.html
I'm using the railstutorial at http://ruby.railstutorial.org/chapters/rails-flavored-ruby#sec:a_user_class
I've been told to type require './example_user' but... I get this error
LoadError: cannot load such file -- example_user
from /Users/snook3/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:251:in require'
and then further and further errors
I imagine that I'm not linking correctly to that folder, can anyone let me know where I should be linking too?
Yes, just move the file to the actual root directoy. Doing mv example_user.rb* / should do it.
Also, don't worry if after requiring the file, you get a return of "true" instead of ["User"].
You can use
Rails.root
to get your current Rails project root.
So
require Rails.root + 'path_to_example_user'
would load the file.
You can also try the reload! command, which will reload the whole Rails environment.
The file should end with .rb:
require './example_user' #will not work
require './example_user.rb' #will work
To rename the file, use the following command line (not in the rails console):
mv example_user example_user.rb
try using absolute path for the file... something like this:
require '/Users/snook3/my/project/folder/example_user.rb'
No need to specify the full path, simply append .rb to the filename: require './example_user.rb'.
I had this exact same problem, but not being very familiar with Unix I can only explain it like this.
1) I created the example_user.rb file in Sublime Text 2 and saved it to the application root folder.
2) The "require" wasn't working for me, just like the OP. Even though I could see the file there in the folder.
3) However, opening up a Terminal window, navigating to the application root, and entering "dir", I could then see that the filename had a "/ " before it!? Not sure how/why that happened, or why it wasn't visible in Explorer (or whatever the Unix equivalent of that is called--Nautilus?).
4) After renaming the file from within Terminal, it all worked. But would love an explanation of what went wrong if this makes sense to any of you Unix/Rails folks.
Try
touch example_user.rb
in Unix terminal. And then add code to this file.
The tutorial tells you to "create the file example_user.rb in your application root directory". I mistakenly initially put it in the app folder and got the same error message.
If you instead move the file into your project root directory, then require './example_user' will work.