IntelliJ Ruby syntax highlighting - ruby-on-rails

I am having some issues with getting IntelliJ to properly recognize my Ruby / Rails application syntax.
Screenshot here:
http://www.evernote.com/shard/s5/sh/4a3072c9-0439-4d31-aa16-85796d1a011a/ed4017710a5dcf700396c751011dae74
I have the Ruby plugin installed. I also have the Rails gem and other gems installed, but no go.
Any idaes?

(The question was posted a while ago but I want to make #mattalxndr's wish come true :-) )
This looks like an issue with the Hash notation and not color highlighting.
The wiggly red line indicates that IntelliJ is not recognizing the {symbol: "value"} syntax. In contrast, {:jobs => #jobs} is valid on the same line.
This syntax was introduced in Ruby 1.9.
Solution: Go to the SDK tab in the Project Structure window and make sure that you are using ruby 1.9 or higher.
BTW, you can switch between the two notations by placing the cursor on the symbol and invoking the "Show intention action" function (in OSX the keys are ⎇⏎).

Related

How do make snippets work for Ruby On Rails in Textmate 2?

On a fresh install of Textmate2, you used to be able to type hm<tab> while editing in a model and it would type out a whole has_many line for you, but now it just types a tab. All of the text-completion seems broken. The ones from Ruby are still working (def<tab> creates a method block with the name selected, for instance).
I noticed that the "Ruby on Rails" bundle wasn't enabled by default anymore, but I fixed that and the issue remains.
The snippets still work, but you have to make sure that the language mode is set to "Ruby On Rails" in the bottom status bar, otherwise they won't trigger.

Rails slim syntax errors - config wrong?

I just merged the redesign branch in our rails app, and now we use slim. Everyone seems to have it working fine, but if I try browsing the new website (without any code modification), I get syntax errors like:
unexpected ':', expecting keyword_end
Here is a snippet of the slim file, above error is on the last line, but I'm pretty sure this has nothing to do with the file as others devs don't have the problem, neither does the production site.
#featured-destinations-carousel.carousel.slide data-ride="carousel" data-interval="15000"
.pagination.hidden-sm.hidden-xs
= link_to "#featured-destinations-carousel", 'data-slide': 'prev' do
I was told to upgrade to Ruby 2.2+, I did (with rbenv), but that didn't fix it. Ideas?
Your upgrade hasn't worked properly, the Rails app is still using and older version of Ruby. Make sure your rbenv is set up properly (do ruby -v and which ruby to help debug before running rails s) and that your .ruby-version file has the correct version in it.
You're super close. Just need to change it to
= link_to "#featured-destinations-carousel", 'data-slide' => 'prev' do
instead.

How to set up Ruby / RoR methods autocomplete with sublimecodeintel in Sublime Text 3?

Goal: Using sublimecodeintel + ctags, have Sublime text 3 autocomplete show available methods for each class.
Example: typing "[1,2,3]." should give options like
to_s
.to_a
.to_ary
.empty?
I have searched extensively on the topic for the past couple of days. the idea is to make sublime text aware of the RVM-Ruby being used for the project and have autocomplete prompt the available methods.
This isn't a sublime text 3 (build 3047, osx mavericks), sublimecodeintel or ctags issue.
Sublimecodeintel is verified working - it autocompletes for classes defined in project.
ctags have been installed using brew. and the built up tags file contains tags from across the project. Its more of a correct set of settings / order of installing the plugins to get it working.
Any help would be much appreciated!
I think that you want this: go in View -> Syntax -> Rails
for the use highlights CTRL+SPACE

Ruby on Rails command line looks weird

I just began learning RoR using the materials from railstutorial.org. When the author uses the command line, the resulting text are always nicely organized and colored. When I do the same thing, I often get "weird" characters and unorganized text as result.
http://i.imgur.com/2Q0kzwf.jpg
Example
http://i.imgur.com/mZP4SI9.jpg
My attempt to do the same
I'm not quite sure what to do to make my command line more organized like the one shown in the tutorial. Any help would be appreciated. In case you need to know, I'm using Windows 7.
It is because by default Windows command prompt doesn't know about ANSI color Sequences. You can try https://github.com/adoxa/ansicon which is supposed to make it aware. The reason the tutorial authors look like that is they are using a *nix shell that understands the color codes (probably bash or zsh on either linux or osx if I had to guess)
As Doon pointed out, the Windows console doesn't recognize ANSI sequences. As suggested your best bet right now is to use external tools.
However, since there are some pain points using most of the external tools, Ruby 2.0 will provide support for ANSI escape codes in Ruby out-of-the-box without having to depend on external gems or tools.

Can Ruby 1.9 used with Rails by a Ruby/Rails beginner?

About half a year ago, when I started to learn Ruby and Rails, I first tried Ruby 1.9 but I soon gave up, because at that time nothing worked out of the box and almost every helping blog or tutorial was designed for Ruby 1.8.
What about now? (Dec 2009) Is it possible to get an existing Rails application running by a Ruby and Rails beginner without running into problems which can only be fixed by an absolute Ruby and Rails professional?
Unfortunately I dind't have good experiences with Ruby 1.9 and Rails.
You can read more here: Has anyone successfully deployed a Rails project with Ruby 1.9.1?
My opinion is that migrating an existing Rails app from Ruby 1.8.x to Ruby 1.9.1 is not as easy as you would think, event with an excellent test suite.
I'm also quite sure that most of the problems arise from trying to convert an existing application because you are working with an established code base.
Starting with a new Rails app with Ruby 1.9 should probably easier because you can trace a problem as soon as you write a single line of code so you can easily isolate which component is not compatible.
When migrating an existing app I had hard time trying to figure out which stack level was actually not compatible with Ruby 1.9. And there are more than one incompatible libraries at the same time I can't tell you how it's difficult to understand which one should be fixed first and which one originated the final error.
In 99.9% of the cases yes, there were rare cases where u might find problems but they should be solved with the new release.
As for the external gems and plugins, most of them now are fully compatible with ruby 1.9, however sepcial cases might exist but I'm not aware of any right now.

Resources