I have Textmate 1.5.7 running on my leopard machine.
When programming in rails, for some reason some key words do not get highlighted.
For example: validates_presence_of, has_many, remote_form_for (form_for gets highlighted) etc...
I tried switching themes and it did not help. I also tried upgrading to the most recent rails bundle but no cigar. Could someone please help?
Use RubyOnRails as your language rather than Ruby
If you're editing views like .erb files you'll want to select HTML (Rails) so the remote_form_for, etc. get properly highlighted. For everything else (controllers, models, migrations, etc.) like #Omar points out, make sure you've got Ruby on Rails selected.
Just a quick note for other lurkers -- it took me a little while to figure out how to change languages on TextMate. You can do it through the Bundle Editor, which will show you the shortcut as well...
Related
I am a beginner in this whole thing. I have previously used Sublime for HTML and CSS practice. Now I want to work on a website using Ruby, but do not know how to set up Sublime for rails, since every tutorial for Ruby has those files in the left side of the Sublime window, like App directory and similar generated somehow. I would not like to work blindfolded. I have tried to find a way to generate those directories, but did not find any step by step instructions. Which are welcomed in this case. I would appreciate those, or if there is a link to some detailed tutorial on how to do that. Thanks in advance for any help!
There is a blog that I hope it would help you in your case.
Here it is: Setting up Sublime Text 3 for Rails Development
The directories you're talking about (app, config, etc.) aren't generated by SublimeText; they're generated by Rails when you create a new application with rails new at the command line.
Once you've created the application, you can open the top-level directory in SublimeText, and you'll see all the directories in your sidebar. For example, if you keep your apps in a directory called my_app, and you want to create a Rails app called new_app, you can do this from your terminal:
cd my_apps
rails new new_app
subl new_app
And you should see something like this:
For more on how to get started with Rails, I'd recommend Michael Hartl's Ruby on Rails tutorial.
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.
I don't like using the console terminal. Is it possible to use a text editor like bracket *(MY FAVORITE) to write ruby code? I've seen ruby files. Are those written on an editor? Or is it the case that all these schools teach you the basics through the console and later you can write code on an editor?
Ruby do not have to be written in the terminal.
I myself do most of my coding in sublime and do run some commands in the terminal to run tests and generate some files. (Rails generators are quite awesome by the way)
I have a colleague who uses Ruby mine and from what I understand you can use that to do rails development without using the console.
Yes obviously you can use text editors.
You can write code in editor save it as file_name.rb and run from console as ruby file_name.rb
And this is just a start with Ruby. Just give your 20 minutes and you will get to know
https://www.ruby-lang.org/en/documentation/quickstart/
When you will get familiar with all the great things about ruby
You can start with Rails, as it's name suggests it actually get you started
http://guides.rubyonrails.org/getting_started.html
Just go on and you get fell in love with Ruby on Rails what it is called.
It's a lot convenient to use text editors and write codes instead of giving yourself a hard time coding using the console.
Sublime Text is one of the widely used editors, very easy to use and free. I've always used this.
You could also check out some of the best editors here 5 Best editors - Lifehacker
You can use any text editor and save the codes with the .rb extension <file-name>.rb and run it through terminal like this: ruby filename.rb
I know this is common in 'full featured' IDE's and not text editors but TextMate walks a unique line with its many bundles... I'm wondering if there is an easy way to, say, click on a Ruby or Rails class or method and have TextMate (or shell) take me to the definition or some documentation?
There's one built into the rails bundle (^h) which uses api dock.
Another pretty nice way of doing it is using the rails os x dictionary, but it has a few downsides and I'm not sure what version of rails it's using (I'm pretty sure it's not rails 3, but I haven't checked).
Ctrl-H is an excellent option to learn about Ruby or Rails API.
But this doesn't work for any other methods or class that may be defined or included in your project. For those I've written a TextMate Bundle command (you can easily assign it to Ctrl+] for example) that lookup for the definition of the class or method under the caret and displays it in a tooltip, along with the file name and the line where it was find.
Check it out: Add a shortcut to TextMate to lookup a class or method definition in a tooltip
Hope you'll find it useful ;)
Edit:
Below is my original question. After solving my problem, I thought I'd re-edit this so others may benefit. The root question is "A certain subset of textmate snippets aren't working."
Original Question:
In Textmate, I can't use ruby on rails migration snippets like mtab⇥, mcol⇥, or t.⇥ in my db/migrate/ files. I've tried setting the file type as "Ruby on Rails" as well as "Ruby" and even "Sinatra" but have had no luck. These commands do work when I go through the bundle menu however. What am I doing wrong?
I had ActiveRecord::Migration misspelled so the snippets that rely on matching that string were failing! Always check the snippets source! :)