Rails 3, make exception links clickable and open in editor (textmate) - ruby-on-rails

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 = []

Related

Correct file in production mode Ruby on rails

In my web site, i found a mistake inside a text on my html (langage => language)
I change directly here /app/views/ with vi text editor but when I reload my page (after navigator history cleanning). The mistake is still here
There is a kind of step to take in account the modification?
Thanks in advance
In Production you normally have to restart the server for changes to take place

How to configure better errors rails for firefox

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.

Migrating to Vim from RubyMine - Interpreted Auto completion

Up until last week, I had been using RubyMine for my Rails development. I know it has a vim plugin but I have been working on migrating my development to vim and tmux. I don't want to keep using the mouse and VIM gives me a lot more flexibility. I have found plugins and workarounds for almost all the features I care about except the "interpreted auto complete" functionality in my first screenshot below. RubyMine interprets the whole rails application and offers sorted-by-relevance suggestions (as you can see, it's showing me instance variables and methods for the class in question and the modules it includes) THEN it shows (less relevant) methods available on the Object class. It also shows the method signature when there's one.
Also, in my second screenshot, you can see how RubyMine offers autocompletion for core Ruby classes.
Compare this to the bottommost screenshot. I do have completion but there's no way to find what I'm looking for. I'm using ctags , YouCompleteMe, vim-rails, vim-ruby and I also tried installing eclim to see if it makes a difference.
Is there a plugin I've missed that can enhance my auto completion? It doesn't look like RubyMine is doing something super crazy. pry can give me the same 'power' if it were running in the same 'context'.
First Screenshot (RubyMine interpreted auto complete):
Second Screenshot (RubyMine core Ruby classes auto complete):
Third Screenshot (vim omnifunc + ctags):
Important Note
This solution only works for Ruby 1.9+
I forked 'vim-ruby' at https://github.com/zxiest/vim-ruby and modified it as such:
Method signatures now appear in completion.
I disabled sorting by name for methods.
Plugins and Settings
vim-rails
I'm using vim-rails https://github.com/tpope/vim-rails
supertab
I'm using supertab https://github.com/ervandew/supertab instead of YouCompleteMe (mentioned in my question) although YouCompleteMe is super fast and automatic but there are currently some compatibility issues between my it and my vim-ruby fork.
vim-easytags
I'm using vim-easytags https://github.com/xolox/vim-easytags
Add this to your ~/.vimrc
:set tags=./tags;
:let g:easytags_dynamic_files = 1
Make sure to touch ./tags in your project directory.
Issue :UpdateTags -R **/*.* from vim in order for easytags to generate your tags file.
Remap omnicomplete
In order for omnicomplete to pop up, by default, we have to hit <C-X><C-O>. I remapped this to <C-Space> by inserting the following in my ~/.vimrc:
inoremap <C-#> <C-x><C-o>
I now press tab when I want supertab to complete my code and Ctrl+Space when I want omnicomplete to trigger and show method signatures for me. There's definitely a better way to integrate this (i.e. getting supertab to call omnicomplete after a dot)
And here goes the screenshot! Notice that method sorting being off allowed my custom resize method to appear on top and the signatures now appear in the completion (as well as in the editor when enter is pressed!)

open sublime with custom url scheme

The rails gem better provides a nice interface to debug rails web applications. Clicking on file names should open your preferred text editor e.g. TextMate. With Sublime however, nothing happens.
How is it possible to register a url scheme handler for subl:// ?
Had the same problem. After some searching I found the subl-handler on github.
You need to setup your sublime so you can use the subl-command in your terminal. Look for this guide.
Installing solved the problem.

rails view not updating

I have started with my first rails project using Redmine. I have started to dig into the code to get a better idea and having a hard time understanding the erb files. When I go to make a simple change to the welcome.html.erb file, I make the change and check in the browser and there is no change. Once I save a file is there something that I need to run before the view will be updated? I did not think so, but that is why I am here asking because the view will not update the page when I save the file.
Thank you in advance for any help.
UPDATE: After I update the .html.erb file and open it up again in vim, my changes are still there. Only problem is that the page does not reflect what the change has been made to and when I view source it is not there either?????
It looks as though my cloud server is slow to update the pages so I need to check and see why this is. There is no problem with the pages when working locally and the page was updated in the source the next morning.
Using an IDE is not a good idea when you're learning Rails.
Try opening a console and cd into your application directory. Then run rails s and you should see your application running on a browser when you point to localhost:3000
You can leave the server running and modify your view file with any text editor. Changes should reflect automatically without even need to restart the server.
HTH!

Resources