How to configure better errors rails for firefox - ruby-on-rails

how to configure better errors for ROR on linux with firefox. Better errors gem is useful to open rails application error file with line number from browser only, so it will be less time consuming for developer to correct the error and no need to search file and line separately

First of all download and install sublime url handler patch to handle the url with line number. Download sublime-url-handler.
Goto to development.rb file and add BetterErrors.editor = :sublime
Goto firefox and type about:config in url and hit enter
Right click and create new property with boolean type with name " network.protocol-handler.expose.subl" set "False".
Restart firefox.
Run your rails app and get the error link page, click on error link it will ask open open with if sublime-url-hanlder is shown here well done choose and cheers if not shown than give your sublime executable path here and done.
Remember give sublime executable path only not /usr/bin/subl, or shared lib path. You can find the executable path by running subl and see the process details like "ps -eaf | grep subl" copy the path and give this path in firefox choose application.

Related

dev tools console: don't show path in the links of console messages?

Is it possible to make chrome dev tool's console shorten the source code link by only showing the base file name and line number without the whole path?
--BobG

Authorize UNIX command to control an application

I want to set up an Automator Quick Action that runs the bbdiff command, and passes it the selected files in the Finder.
I created a Quick Action, and set it to receive "files or folders" in "Finder.app".
Then I added the "Run Shell Script" action, and set the shell to "/bin/bash", and to Pass Input "as arguments". The script is:
/usr/local/bin/bbdiff "$1" "$2"
If I run that script manually from Automator or Terminal (replacing the arguments with real filenames) it prompts me to authorize the host program to control BBEdit, and then it works.
But if I run it from the Finder, I get this error:
The action “Run Shell Script” encountered an error: “You must allow bbdiff to send events to the BBEdit application.
Use tccutil reset AppleEvents to reset the system's permissions, and try again.
bbdiff: error: -1743”
I tried running tccutil reset AppleEvents and running the action again, but it showed the same error.
I also tried adding bbdiff, /bin/bash, and Finder to the Accessibility and Full Disk Access tabs of System Preferences > Privacy, but nothing changed. It looks like you need to add something to the Automation tab, which can't be done manually.
How can I get it to allow a UNIX command like bbdiff to control an application?
UPDATE:
I managed to work around this by using a "Run AppleScript" action, instead of "Run Shell Script", with this script:
on run {input, parameters}
tell application "BBEdit" to compare (item 1 of input) against (item 2 of input)
return input
end run
The first time I ran it, I got the prompt to allow Finder to control BBEdit, and then it worked.
But this wouldn't work for other shell scripts, so the question is still open.
In my case, I was able to fix it simply by closing the currently opened BBEdit then opening it again. In my case, I was doing a BBEdit update before the error appears.

On "bundle open <gemname>": EDITOR environment variable failing? (Windows)

I'm working in Windows 10 on a rails project and want to open up the devise gem to have a look. I'm running bundle open devise, which gives me the following
C:\Users\MyName\Documents\MyRailsProj>bundle open devise
Could not run 'C:Program FilesMicrosoft VS CodeCode.exe C:/Ruby22/lib/ruby/gems/2.2.0/gems/devise-4.4.1'
I've set the environment variable EDITOR to C:\Program Files\Microsoft VS Code\Code.exe in my system, which is the correct location of VS Code on my system. I've also tried setting it to point to sublime3, which has the same result.
I'm guessing I've just set this variable incorrectly, but I don't know how bundle open expects the EDITOR or BUNDLER_EDITOR to be set other than to the path of the program I want to use to open the gem. Any ideas why I can't open the gem?
edit:
I can totally just use bundle show devise so see the gem's location and go find and open it in vs code all I want, but I do also want to know how to use the EDITOR environment variable properly, so I think the question still has merit if anyone has any ideas.
It looks like bundle is treating the environment variable as an escaped string, and so all the path separators are being lost. In addition, it also might not be handling spaces correctly.
However, you might not need the path at all.
If you can open the editor just by typing "Code" at a command prompt, just set EDITOR to
code
Otherwise, instead of setting it to
C:\Program Files\Microsoft VS Code\Code.exe
try
C:\\Program\ Files\\Microsoft\ VS\ Code\\Code.exe
or
"C:/Program Files/Microsoft VS Code/Code.exe"

How to make RSense autocomplete and jump to definitions of a rails project?

I switched from netbeans to emacs and I am pretty happy with the change. The thing I am missing the most is autocompletion and jump to definitions. In order to get this I have installed Rsense. It works fine for the gems code, though, I cannot jump-to-definitions of my Rails project nor autocomplete according to the methods I defined.
I tried to add my project's load path to Rsense's load_path configuration, though, it still doesn't work.
Does anyone know how to get this working?
You can use tags for browsing through files and jumping directly to function definitions.
I use Exuberant Ctags (its got Ruby support). You can download it from here.
I am assuming that you are working on windows. Getting the tags to work initially on windows is a pain especially if you are using emacs for the first time.
These are the steps I followed:
Install Cygwin from here.
Include the cygwin\bin\ folder in your environment variable PATH. E.g. here
Install exhuberant ctags. Note that emacs may sometime have a built in ctags. Later on you will have to use the ctags command in cygwin to create tags. At that time you may encounter some errors in case it uses the ctags in emacs instead of exuberant ctag.
Once you have installed ctags, add that to the environmental variable PATH as well.
If you have a small project with relatively lesser number of files (<500). So you just need a single global TAGS file. For that open cygwin, change your directory to the root directory of your project and type in the command ctags -R -e Check this out for other approaches
Your tags file will be created. It will be named "TAGS" and will be present in the root directory of your project.
Next open emacs, and browse through the code. In case you come across a function and want to jump to its definition, put your cursor on the function name and press M-. your minibuffer should then show something like Find tag (default <function-name>): Press Enter and voila!!! you are magically transported to the function definition!!!
Note: You may have to specify the TAGS file the first time you use the M-. This needs to be done only once after emacs startup. You can also modify your .emacs file to take in the TAGS file automatically on startup.
Refer to this and this for more info for tags related commands in emacs.
Until now, I have been using rtags to jump to definitions. It's not perfect, but it does the trick in many cases.

Rails 3, make exception links clickable and open in editor (textmate)

I have a Rails 3 installation running on a remote development server. Is it possible to make the exception lines clickable and open in an editor like textmate on my local maschine? I would save a lot of time if I did not have to manually open textmate, find file and line number.
NoMethodError in Arts#index
Showing /home/demo1/app/widgets/art_widgets/list/display.html.erb where line #9 raised:
Best regards.
Asbjørn Morell
Just found a great plugin that does exactly this! rails-stacktrace-textmate-linker-greasemonkey-script
Install greasemonkey from here: http://addons.mozilla.org/en-US/firefox/addon/748
Install rails-stacktrace-textmate-linker by clicking the link in the install section: https://github.com/ryankshaw/rails-stacktrace-textmate-linker-greasemonkey-script This will load the greasemonkey-script.
Go to Add-ons -> User Scripts -> Right click the Rails Stacktrace Linker and click edit.
Edit line 37 and 49. You will need to add the path to your rails Application.
... href='txmt://open?url=file:///Users/atmorell/Dropbox/MorellusWallace/", ...
Reload your application in firefox and enjoy nice clickable stacktrace that opens in textmate :)
WINNING!
Not in a simple way.
You'd need a software running in the background that would interpret the exception page to put links in it, and then open the software, file and find the line specified. As far as I know, there's no first-party solution.
I also wanted textmate link(txmt://) in Rails Error Page. But until now no success.
rails-footnotes has similar feature. It insert txmt link to every page. But not in Error page.
someone on rails-talk mailing list asked same question. and said merb had that feature.
Adding the rails footnotes gem will give you clickable file references in your application trace.
https://github.com/josevalim/rails-footnotes
I found this gem slowed my dev environment down a little so disabled it's main functionality, I only needed it purely for the clickable file references. You can do this by adding the following line in the .rails_footnotes file in the root of your app.
Footnotes::Filter.notes = []

Resources