GithubHelp home page GithubHelp logo

sublime-rails-snippets's Introduction

Sublime Text Rails snippets

The repo aims to replace the default Rails snippets from Sublime Text and make it useful for the latest Ruby and Rails versions. All the snippets can be found in this cheatsheet generated by Snipcheat.

class

ActiveRecord

migrations

Installation

From Git

cd ~/Library/Application\ Support/Sublime\ Text\ 2/Packages
➜ git clone https://github.com/tadast/sublime-rails-snippets.git Rails

It is important to clone it into a folder called Rails. Some Sublime plugins have hardcoded dependencies pointing to that path. See troubleshooting.

From Package Control

Look for "Ruby on Rails snippets". Here's how to install packages

Please Note: If you're a Sublime Text 3 user you'd need to tell your editor to use the Ruby on Rails syntax provided by Ruby on Rails Snippets. One can find this option in the editor by navigating their way via - View -> Syntax -> Open all with current extension as... -> Ruby on Rails Snippets -> Ruby on Rails

Housekeeping

⚠️ You will need to do some housekeeping after installing it from Package Control. First of all, remove the original Rails directory (see Backup). Then quit Sublime and delete Sublime's session cache.

rm ~/Library/Application\ Support/Sublime\ Text\ 2/Settings/Session.sublime_session

This will lose all session data (Sublime will 'forget' open filetabs, projects, search history etc.)

Troubleshooting

Can't find *.tmLanguage

If Sublime complains it can't find Ruby on Rails.tmLanguage, chances are you are using this hack.

You'll need to change the path where it looks for that file. Here's the forked version which works with this plugin.

You may also need to change Packages/(DetectSyntax|User)/DetectSyntax.sublime-settings to replace/include this rule

{
  "name": "Ruby on Rails snippets/Ruby Haml",
  "rules": [
    {"file_name": ".*\\.haml$"}
  ]
},
{
  "name": "Ruby on Rails snippets/Ruby on Rails",
  "rules": [
    {"function": {"name": "is_rails_file"}}
  ]
}

Ruby on Rails snippets is a default instalation directory for Package Control. If you installed in a different directory, change the path accordingly

Sublime picks Ruby syntax

You may need to tell Sublime to prefer Rails View -> Syntax -> Open all with current extension as... and pick Rails of Ruby on Rails snippets

How to contribute

  1. Fork it
  2. Create your feature branch for each group of snippet changes that could be merged individually (git checkout -b my-new-snippet)
  3. Commit your changes (git commit -am 'Add some snippet [tab_trigger]')
  4. Commit messages should start with a verb in present simple tense and have all affected tab triggers in square brackets e.g. "Add a snippets for partial rendering [rpc, rpo]"
  5. Push to the branch (git push origin my-new-snippet)
  6. Create new Pull Request

sublime-rails-snippets's People

Contributors

tadast avatar bronson avatar akzhan avatar miharekar avatar boddhisattva avatar raldred avatar doabit avatar

Watchers

James Cloos avatar Jones avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.