Git Product home page Git Product logo

projectile-rails's Introduction

Melpa Status Melpa Stable Status Build Status

Projectile Rails

Synopsis

Projectile Rails is a minor mode for working with Ruby on Rails applications and engines in GNU Emacs. Internally it is based on Projectile.

It means that you can use Projectile's commands for greping (or acking) files, run tests, switch between projects, etc.

With Projectile Rails you are able to:

  • navigate through rails resources (controllers, views, helpers and so on)
  • jump to ruby classes and template files
  • run rake
  • run rails console
  • run rails dbconsole
  • run rails generate
  • run rails server
  • open log files with auto-revert-mode on
  • see rails keywords highlighted
  • take advantage of zeus and spring preloaders

It can be a replacement for rinari.

Setup

Installation

MELPA

Once you have setup Melpa you can use package-install command to install Projectile Rails. The package name is projectile-rails.

el-get

The package name for el-get is projectile-rails.

Usage

The global mode

Use the package as a global mode:

(projectile-rails-global-mode)

That will turn on the local projectile-rails-mode for the buffers which belong to a Rails project (either application or an engine).

Probably you should read Projectile's README on setting up the completion system, caching and indexing files. Although the default settings are quite sensible and you should be ready to go without much tweaking.

Customizing

Keymap prefix

Prior to version 0.20.0 the keymap prefix used to be setup. Following the convention we have stopped doing this automatically. Now you need to attach the mode's map to the desired key yourself. For example to get the old key you can do:

(define-key projectile-rails-mode-map (kbd "C-c r") 'projectile-rails-command-map)

Keywords

The mode's buffers will have the Rails keywords highlighted. To turn it off:

(setq projectile-rails-add-keywords nil)

Snippets

If you have yas-minor-mode or yas-global-mode and auto-insert-mode enabled and you open a new file it will be filled with a skeleton class. To turn it off:

(setq projectile-rails-expand-snippet nil)

Note: this variable controls whether auto-insert-mode is configured, that is if you set this variable to nil after you opened any rails file the snippets will still be inserted. In order to disable this feature in such scenarios just disable auto-insert-mode instead.

ANSI Colors

By default the buffer of the projectile-rails-server-mode is applying the ansi colors. If you find it slow you can disable it with:

(setq projectile-rails-server-mode-ansi-colors nil)

External commands

You can customize the way the rails, spring and zeus commands are invoked. For example if you want to use binstubs:

(setq projectile-rails-vanilla-command "bin/rails"
      projectile-rails-spring-command "bin/spring"
      projectile-rails-zeus-command "bin/zeus")

Interactive commands

The keymap is unbound by default. The following keybinding assume that you've bound it to C-c r. See Keymap prefix section for details.

Command Keybinding Description
projectile-rails-find-model C-c r m Find a model using projectile-completion-system.
projectile-rails-find-current-model C-c r M Go to a model connected with the current resource.
projectile-rails-find-controller C-c r c Find a controller using projectile-completion-system.
projectile-rails-find-current-controller C-c r C Go to a controller connected with the current resource.
projectile-rails-find-view C-c r v Find a template or partial using projectile-completion-system.
projectile-rails-find-current-view C-c r V Go to a view connected with the current resource.
projectile-rails-find-helper C-c r h Find a helper using projectile-completion-system.
projectile-rails-find-current-helper C-c r H Go to a helper connected with the current resource.
projectile-rails-find-lib C-c r l Find a lib using projectile-completion-system.
projectile-rails-find-feature C-c r f Find a feature using projectile-completion-system.
projectile-rails-find-spec C-c r p Find a spec using projectile-completion-system.
projectile-rails-find-current-spec C-c r P Go to a spec connected with the current resource.
projectile-rails-find-test C-c r t Find a test using projectile-completion-system.
projectile-rails-find-current-test C-c r T Go to a test connected with the current resource.
projectile-rails-find-migration C-c r n Find a migration using projectile-completion-system.
projectile-rails-find-current-migration C-c r N Go to a migration connected with the current resource.
projectile-rails-find-fixture C-c r u Find a fixture using projectile-completion-system.
projectile-rails-find-current-fixture C-c r U Go to a fixture connected with the current resource.
projectile-rails-find-javascript C-c r j Find a javascript using projectile-completion-system.
projectile-rails-find-stylesheet C-c r s Find a stylesheet using projectile-completion-system.
projectile-rails-find-log C-c r o Find a log file and enable auto-revert-tail-mode in its buffer.
projectile-rails-find-initializer C-c r i Find an initializer file using projectile-completion-system.
projectile-rails-find-environment C-c r e Find an environment file using projectile-completion-system.
projectile-rails-find-locale C-c r a Find a locale file using projectile-completion-system.
projectile-rails-find-mailer C-c r @ Find a mailer file using projectile-completion-system.
projectile-rails-find-validator C-c r ! Find a validator file using projectile-completion-system.
projectile-rails-find-layout C-c r y Find a layout file using projectile-completion-system.
projectile-rails-find-rake-task C-c r k Find a rake task file using rake-completion-system.
projectile-rails-find-job C-c r b Find a job file using projectile-completion-system.
projectile-rails-dbconsole C-c r ! b Run rails dbconsole command in sql-interactive-mode.
projectile-rails-console C-c r ! c, C-c r r Run rails console command in inf-ruby buffer.
projectile-rails-server C-c r ! s, C-c r R Run rails server.
projectile-rails-rake C-c r ! r Select a rake task to run using rake-completion-system.
projectile-rails-generate C-c r ! g Run rails generate command.
projectile-rails-extract-region C-c r x Extract the selected region to a partial.
projectile-rails-goto-file-at-point C-c r RET, C-c r g f Go to a file at point. Depending on the context that might be a constant, template or partial, or a gem.
projectile-rails-goto-gemfile C-c r g g Go to Gemfile file.
projectile-rails-goto-routes C-c r g r Go to config/routes.rb file.
projectile-rails-goto-schema C-c r g d Go to db/schema.rb file.
projectile-rails-goto-seeds C-c r g s Go to db/seeds.rb file.
projectile-rails-goto-spec-helper C-c r g h Go to spec/spec_helper.rb file.

You might want to create your own keybinding for your favorite commands. For example:

(define-key projectile-rails-mode-map (kbd "s-m")   'projectile-rails-find-model)
(define-key projectile-rails-mode-map (kbd "s-c")   'projectile-rails-find-controller)
(define-key projectile-rails-mode-map (kbd "s-v")   'projectile-rails-find-view)
(define-key projectile-rails-mode-map (kbd "s-RET") 'projectile-rails-goto-file-at-point)
(define-key projectile-rails-mode-map (kbd "C-c g")  projectile-rails-mode-goto-map)

Discover

There's also integration with discover.el. The key that trigger the menu is s-r (the "s" stands for Win/Command key).

Screenshot

Hydra

There's also integration with hydra. The name of the hydra hydra-projectile-rails. In order to bind it you can something like this:

(define-key projectile-rails-mode-map (kbd "s-r") 'hydra-projectile-rails/body)

Beyond

Consider installing other Emacs packages that can help you working specifically with Rails projects.

Templates

Extension Alternatives
erb web-mode, mmm-mode, rhtml-mode
haml haml-mode
slim emacs-slim
yaml yaml-mode

Running ruby gems

Some of the Projectile Rails functions run rake or rails executables. If you are using a ruby version manager you might need to configure your Emacs to play nicely with it.

OS X users might want to look at exec-path-from-shell.

Miscellaneous

Caveat

Running pry instead of irb

  • Pry's paging is not working in emacs. It should be disabled with Pry.config.pager = false if ENV["INSIDE_EMACS"]. Reference.

  • When projectile-rails-console runs rails console using a pre-loader (zeus or spring) and pry's indent correction is enabled then pry will insert some ansi codes that are misinterpreted by comint-mode. A workaround is to disable the indentation correction with Pry.config.correct_indent = false. Reference. Issue.

Debugging

To use binding.pry or byebug, install inf-ruby and add this to your init file:

(add-hook 'after-init-hook 'inf-ruby-switch-setup)

Contributors

Here's a list of the people that contributed to the projects. Many thanks! :)

Contribution

Install cask if you haven't already, then:

$ cd /path/to/projectile-rails
$ cask

Run all tests with:

$ make test

For all of them to pass you will need the bundle executable in your path.

projectile-rails's People

Contributors

a3ammar avatar asok avatar caleb avatar chopmo avatar constantinexvi avatar dcluna avatar dgtized avatar ejoubaud avatar expez avatar fritzgrabo avatar hbin avatar imtayadeway avatar j3rn avatar jdelstrother avatar jeizsm avatar jmay avatar keegnotrub avatar knu avatar mattdeboard avatar mbreit avatar otavioschwanck avatar pedz avatar phelrine avatar purcell avatar shanavas786 avatar silex avatar smaximov avatar syohex avatar victorteokw avatar w11th avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

projectile-rails's Issues

Running server/console fails with RVM and ZSH

On OS X whenever I start the server I get:

`validate_ruby!': Your Ruby version is 2.0.0, but your Gemfile specified 2.1.2 (Bundler::RubyVersionMismatch)

I've had the same issue with rspec mode which solves the problem here. Is it possible to adopt that solution here?

dbconsole

How can I start rails db with projectile-rails?

Check for ZEUSSOCK environment variable

The ZEUSSOCK environment variable can specify an alternative location for the zeus socket file. projectile-rails-zeus-p should check for this env variable to see if zeus is running. If the variable does not exist then fall back to the current behavior.

create files when not found

When I find controller file with projectile-rails-find-controller to find articles controller ArticlesController.

When I input an non-exist controller articles, it report error: Wrong type argument: stringp, nil

I hope projectile-rails can auto create file if not found. and also auto generate file content like:

class ArticlesController < ApplicationController
end

cannot display ansi code correctly when run rake spec

the output:

bundle exec rake default
/home/chylli/.rvm/rubies/ruby-2.1.2/bin/ruby -I/home/chylli/.rvm/gems/ruby-2.1.2@rails4/gems/rspec-core-3.0.2/lib:/home/chylli/.rvm/gems/ruby-2.1.2@rails4/gems/rspec-support-3.0.2/lib -S /home/chylli/.rvm/gems/ruby-2.1.2@rails4/gems/rspec-core-3.0.2/exe/rspec ./spec/controllers/accounts_controller_spec.rb ./spec/controllers/application_controller_spec.rb ./spec/controllers/categories_controller_spec.rb ./spec/controllers/configure_controller_spec.rb ./spec/controllers/sessions_controller_spec.rb ./spec/controllers/transaction_categories_controller_spec.rb ./spec/controllers/transactions_controller_spec.rb ./spec/controllers/users_controller_spec.rb ./spec/helpers/accounts_helper_spec.rb ./spec/helpers/categories_helper_spec.rb ./spec/models/account_spec.rb ./spec/models/category_spec.rb ./spec/models/currency_spec.rb ./spec/models/transaction_category_spec.rb ./spec/models/transaction_spec.rb ./spec/models/user_spec.rb ./spec/routing/accounts_routing_spec.rb ./spec/routing/categories_routing_spec.rb ./spec/routing/sessions_routing_spec.rb ./spec/routing/transaction_categories_routing_spec.rb ./spec/routing/transactions_routing_spec.rb ./spec/routing/users_routing_spec.rb ./spec/views/accounts/edit.html.erb_spec.rb ./spec/views/accounts/index.html.erb_spec.rb ./spec/views/accounts/new.html.erb_spec.rb ./spec/views/accounts/show.html.erb_spec.rb ./spec/views/categories/edit.html.erb_spec.rb ./spec/views/categories/index.html.erb_spec.rb ./spec/views/categories/new.html.erb_spec.rb ./spec/views/categories/show.html.erb_spec.rb ./spec/views/configure/account_categories.html.haml_spec.rb ./spec/views/configure/accounts.html.haml_spec.rb ./spec/views/configure/language.html.haml_spec.rb ./spec/views/layouts/application.html.erb_spec.rb ./spec/views/transaction_categories/edit.html.erb_spec.rb ./spec/views/transaction_categories/index.html.erb_spec.rb ./spec/views/transaction_categories/new.html.erb_spec.rb ./spec/views/transaction_categories/show.html.erb_spec.rb ./spec/views/transactions/edit.html.erb_spec.rb ./spec/views/transactions/index.html.erb_spec.rb ./spec/views/transactions/new.html.erb_spec.rb ./spec/views/transactions/show.html.erb_spec.rb ./spec/views/users/edit.html.erb_spec.rb ./spec/views/users/index.html.erb_spec.rb ./spec/views/users/new.html.erb_spec.rb ./spec/views/users/show.html.erb_spec.rb
�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m�[32m.�[0m

List all the resources of the same kind when there is no correspondent current resource

screen shot 2014-05-27 at 7 45 14 pm
As the image above suggests, even if there is no area_controller.rb, when I call projectile-rails-find-current-controller, projectile-rails still asked me "Which exactly?" This is silly, I think it is supposed to return all the controllers when it can't find the 'current' controller. Here is the code of projectile-rails-find-current-resource:

(defmacro projectile-rails-find-current-resource (dir re)
  "RE will be the argument to `s-lex-format'.

The binded variables are \"singular\" and \"plural\"."
  `(let* ((singular (projectile-rails-current-resource-name))
          (plural (pluralize-string singular))
          (files (--filter
                  (string-match-p (s-lex-format ,re) it)
                  (projectile-dir-files (projectile-expand-root ,dir)))))
     (projectile-rails-goto-file
      (if (= (length files) 1)
          (-first-item files)
        (projectile-completing-read "Which exactly: " files)))))

There should be a conditional check, if files is nil, we should somehow call the projectile-rails-find-resource to list all the resources of the same kind. Similarly, if a user is already in a model file, when he calls projectile-rails-find-current-model, we should list all the models.

Unable to interact with rails server

2016-02-14-110709_621x249_scrot

When using something like binding.pry to open a console, I'm unable to interact with the repl. Is this intentional?

(Note sure if it's noteworthy, but I'm using evil.)

Tabs vs spaces

Hello,

  1. Would you accept a PR that removes all tabs in favor for spaces?
  2. Would you accept a PR that reindents the missindented parts?

1 implies 2 but 2 can be done without 1.

Snippets double expanding

For some reason when I create a new class or test it seems to double expand the snippets so I end up with something like this:

require "spec_helper"

describe Bundle do
require "spec_helper"

  describe Bundle do

  end
end

Missing dependency on f.el

The function project-rails-spring-p using the function f-canonical from f.el, but f.el is not listed as a dependency in projectile-rails-pkg.el, so the melpa install fails when running project-rails-console.

Override ctags just for rails projects

So it's just an idea, but maybe it'd be a good idea to override the ctags generater with ripper-tags if it's available. It offers much better ruby support and I would love to have this happen in my rails projects.

File mode specification error

When I visit a file, I get the following message:

File mode specification error: (void-variable ruby-keyword-end-re)

Not sure what other info to include in this error, so let me know what else you'd need me to do

Error when using RVM when executing projectile-rails-server

Hi,

I'm using RVM to manage multiple ruby versions. Thus bundler for Ruby 2.1 is in ~/.rvm/gems/ruby-2.1.2@global/bin/bundle, for JRuby it is in ~/.rvm/gems/jruby-1.7.12@global/bin/bundle, etc. The PATH variable gets changed by the RVM setup scripts.

But this seems not to work for Emacs. I get this error when executing projectile-rails-server:

-*- mode: projectile-rails-server; default-directory: "~/sites/cforum/" -*-
Projectile Rails Server started at Sun Sep 21 23:37:23

bundle exec rails server
zsh:1: command not found: bundle

Projectile Rails Server exited abnormally with code 127 at Sun Sep 21 23:37:23

Am I doing something wrong?

Local variables entry is missing the suffix when trying to install projectile-rails

Hi, I wanted to install projectile rails but I get this error about inflections package:

BTW I've tried to install it directly from packages list but I get same result.

Debugger entered--Lisp error: (error "Local variables entry is missing the suffix")
  signal(error ("Local variables entry is missing the suffix"))
  error("Local variables entry is missing the suffix")
  hack-local-variables()
  autoload-find-file("inflections.el")
  #[0 "\306\211\211\307\306\310\300!\306\311\300!\306����������:r�\206 \312\300!q\210�;\204T�\313\314\300\"\210�<;\2037�<\202:\315�!\262    \302\203Z�=\316>\203P\302\227\317 \227\232\202T\302\317 \232\204Z\307\262�\212\214~\210�>\203\312\320\321!C\306�\242\203\310�\322\323\324\325\326\327\330�  !\331\"\332\333%D\334\323\335\322EDC\217\240\203\310\320\336!\206\225\337\340\300!!\211\262�\203\310\341�\301����$\211\262�\203\310\342�!\307�?�@\343\344\345\346\347�!��\242BDD\350BB!\210\343\351!\210*\266�eb\210m\204��\352\306w\210\353\354�A!!\203\365\211\204\353\341�\301��\f$\262�\355��\n\300#\210\202\315\353\356!\203��\357y\210\202\315\360\357!\210\357y\210\202\315*\211\203O��\205��pr\342�!q\210\212�b\210\361�!\362\342�!\306�
���\2039�\363��\306\211\364$\202?�\365\366��!8%\210\367�\351\261�\266�)�Bc\210)\210\313\370\300\"\210�\204\\�\371p!\210)\211?\206c��,\207" ["inflections.el" nil "/home/k1/.emacs.d/elpa/inflections-20121016.157/inflections-autoloads.el" float-output-format print-readably print-level nil t get-file-buffer expand-file-name autoload-find-file message "Generating autoloads for %s..." autoload-file-load-name (ms-dos windows-nt) autoload-generated-file lm-header "version" err funcall make-byte-code 0 "\301\300\242!\207" vconcat vector [version-to-list] 2 "\n\n(fn)" error #[257 "\300\207" [nil] 2 "\n\n(fn IGNORED)"] "package" file-name-sans-extension file-name-nondirectory autoload--setup-output marker-buffer princ push purecopy quote intern (package--builtin-versions) "\n" "  \n\f" looking-at regexp-quote autoload--print-cookie-text ";" 1 forward-sexp file-relative-name ...] 21 "\n\n(fn)"]()
  funcall(#[0 "\306\211\211\307\306\310\300!\306\311\300!\306����������:r�\206 \312\300!q\210�;\204T�\313\314\300\"\210�<;\2037�<\202:\315�!\262    \302\203Z�=\316>\203P\302\227\317 \227\232\202T\302\317 \232\204Z\307\262�\212\214~\210�>\203\312\320\321!C\306�\242\203\310�\322\323\324\325\326\327\330�  !\331\"\332\333%D\334\323\335\322EDC\217\240\203\310\320\336!\206\225\337\340\300!!\211\262�\203\310\341�\301����$\211\262�\203\310\342�!\307�?�@\343\344\345\346\347�!��\242BDD\350BB!\210\343\351!\210*\266�eb\210m\204��\352\306w\210\353\354�A!!\203\365\211\204\353\341�\301��\f$\262�\355��\n\300#\210\202\315\353\356!\203��\357y\210\202\315\360\357!\210\357y\210\202\315*\211\203O��\205��pr\342�!q\210\212�b\210\361�!\362\342�!\306�
���\2039�\363��\306\211\364$\202?�\365\366��!8%\210\367�\351\261�\266�)�Bc\210)\210\313\370\300\"\210�\204\\�\371p!\210)\211?\206c��,\207" ["inflections.el" nil "/home/k1/.emacs.d/elpa/inflections-20121016.157/inflections-autoloads.el" float-output-format print-readably print-level nil t get-file-buffer expand-file-name autoload-find-file message "Generating autoloads for %s..." autoload-file-load-name (ms-dos windows-nt) autoload-generated-file lm-header "version" err funcall make-byte-code 0 "\301\300\242!\207" vconcat vector [version-to-list] 2 "\n\n(fn)" error #[257 "\300\207" [nil] 2 "\n\n(fn IGNORED)"] "package" file-name-sans-extension file-name-nondirectory autoload--setup-output marker-buffer princ push purecopy quote intern (package--builtin-versions) "\n" "  \n\f" looking-at regexp-quote autoload--print-cookie-text ";" 1 forward-sexp file-relative-name ...] 21 "\n\n(fn)"])
  autoload-generate-file-autoloads("inflections.el" nil "/home/k1/.emacs.d/elpa/inflections-20121016.157/inflections-autoloads.el")
  update-directory-autoloads("/home/k1/.emacs.d/elpa/inflections-20121016.157")
  package-generate-autoloads(inflections "/home/k1/.emacs.d/elpa/inflections-20121016.157")
  package--make-autoloads-and-stuff([cl-struct-package-desc inflections (20121016 157) "convert english words between singular and plural" nil single "melpa" nil ((:url . "https://github.com/eschulte/jump.el") (:keywords "ruby" "rails" "languages" "oop")) nil] "/home/k1/.emacs.d/elpa/inflections-20121016.157")
  package-unpack([cl-struct-package-desc inflections (20121016 157) "convert english words between singular and plural" nil single "melpa" nil ((:url . "https://github.com/eschulte/jump.el") (:keywords "ruby" "rails" "languages" "oop")) nil])
  package-install-from-archive([cl-struct-package-desc inflections (20121016 157) "convert english words between singular and plural" nil single "melpa" nil ((:url . "https://github.com/eschulte/jump.el") (:keywords "ruby" "rails" "languages" "oop")) nil])
  mapc(package-install-from-archive ([cl-struct-package-desc inflections (20121016 157) "convert english words between singular and plural" nil single "melpa" nil ((:url . "https://github.com/eschulte/jump.el") (:keywords "ruby" "rails" "languages" "oop")) nil] [cl-struct-package-desc projectile-rails (20150826 845) "Minor mode for Rails projects based on projectile-mode" ((projectile (0 12 0)) (inflections (1 1)) (inf-ruby (2 2 6)) (f (0 13 0)) (rake (0 3 2))) single "melpa" nil ((:url . "https://github.com/asok/projectile-rails") (:keywords "rails" "projectile")) nil]))
  package-download-transaction(([cl-struct-package-desc inflections (20121016 157) "convert english words between singular and plural" nil single "melpa" nil ((:url . "https://github.com/eschulte/jump.el") (:keywords "ruby" "rails" "languages" "oop")) nil] [cl-struct-package-desc projectile-rails (20150826 845) "Minor mode for Rails projects based on projectile-mode" ((projectile (0 12 0)) (inflections (1 1)) (inf-ruby (2 2 6)) (f (0 13 0)) (rake (0 3 2))) single "melpa" nil ((:url . "https://github.com/asok/projectile-rails") (:keywords "rails" "projectile")) nil]))
  package-install(projectile-rails)
  (if (package-installed-p package) nil (package-install package))
  prelude-require-package(projectile-rails)
  mapc(prelude-require-package (company-inf-ruby ruby-mode rbenv ruby-electric bundler feature-mode rspec-mode projectile-rails robe))
  prelude-require-packages((company-inf-ruby ruby-mode rbenv ruby-electric bundler feature-mode rspec-mode projectile-rails robe))
  eval((prelude-require-packages (quote (company-inf-ruby ruby-mode rbenv ruby-electric bundler feature-mode rspec-mode projectile-rails robe))) nil)
  eval-last-sexp-1(nil)
  eval-last-sexp(nil)
  #<subr call-interactively>(eval-last-sexp nil nil)
  ad-Advice-call-interactively(#<subr call-interactively> eval-last-sexp nil nil)
  apply(ad-Advice-call-interactively #<subr call-interactively> (eval-last-sexp nil nil))
  call-interactively(eval-last-sexp nil nil)
  command-execute(eval-last-sexp)

Wrong version of spring activated when executing commands with spring

Firstly, let me say that this plugin is really helpful. It's way more featureful than I expected going in (I was just looking for a way to jump around my project).

I have a problem that when I run the commands that use spring (console, rake, etc), I get an error:

You have already activated spring 1.2.0, but your Gemfile requires spring 1.1.3. Prepending `bundle exec` to your command may solve this.

The project I am working on is Rails 4.1 but on this version of ruby I have Rails 4.2 installed as well. I think the problem is that when projectile-rails runs commands with spring it uses plain old spring which uses the newest version of spring.

I think a solution would be to either run with bundle exec as specified in the error message or to run bin/spring from the project directory since that is a wrapper that runs the version of spring in the Gemfile.

What do you think? I could take a crack at a patch, but while my lisp-fu is alright, debugging and hacking emacs is not something I have much experience with.

Thanks again for this project. I am already more productive with it.

support for rails command interactive prompt

when I execute command projectile-rails-generate
I got this problem.

bundle exec rails generate scaffold Article title:string location:string excerpt:string body:text published_at:datetime --skip-migration
Running via Spring preloader in process 14660
      invoke  active_record
   identical    app/models/article.rb
      invoke    test_unit
   identical      test/models/article_test.rb
    conflict      test/fixtures/articles.yml
    Overwrite /home/stardiviner/Code/learning/Ruby/Rails/learning/blog/test/fixtures/articles.yml? (enter "h" for help) [Ynaqdh] 

I can't send yes to it.

Font lock do not play nice with enh-ruby-mode

For example render 'edit' will be highlighted as
render'edit'
It's ok. But if I'll comment it, highlighting do not dissapear:
# render 'edit'
It dissapear only afterM-x enh-ruby-mode:
# render 'edit'

can't use projectile-rails with pry and vimpager

I'm kind of stuck as to what is going on here, there are a few issues that I haven't been able to debug to do with projectile-rails console command. The first is to do with ansi colour codes, they work correctly with ruby mode and opening the shell normally (e.g. with C-c C-s) as below

[1] pry(main)> `echo $TERM`
=> "dumb\n"
[2] pry(main)> ls
#<Class:#<Object:0x00000000e8a3f0>>#methods: 
  inspect
  to_s   
locals: 
  _     
  __    
  _dir_ 
  _ex_  
  _file_
  _in_  
  _out_ 
  _pry_ 
[3] pry(main)> 

however when invoking the projectile rails shell firstly the colour codes don't seem to work, I have tried both turning ans-color-for-comint-mode-on and having export TERM=xterm-256color in my .zshrc.
The second problem seems to be to do with vimpager somehow interacting with pry, both problems can be seen below, I have tried messing with the function

(defun projectile-rails-console ()
  (interactive)
  (projectile-rails-with-root
   (with-current-buffer (run-ruby
             (projectile-rails-with-preloader
              :spring "spring rails console"
              :zeus "zeus console"
              :vanilla "bundle exec rails console"))
     (projectile-rails-mode +1))))

but I can't figure out what I might want to change to fix these problems.
The problems can be seen below:

Loading development environment (Rails 4.0.1)
�[0G�[?1034h[1] pry(main)> `echo $TERM`
`echo $TERM`
�[1A�[0G[1] pry(main)> `echo $TERM`�[1B�[0G/usr/bin/vimpager: line 484: /dev/tty: No such device or address
[2] pry(main)> ls
ls
�[1A�[0G[2] pry(main)> ls�[1B�[0G/usr/bin/vimpager: line 484: /dev/tty: No such device or address
[3] pry(main)> 

Any help with debugging this would be greatly appreciated, I'm more than happy enough to dig through some stuff and try fixing things if people can point me in the right direction.
Thanks for a great plugin.

EDIT: a little detail on my setup, I use emacs, zsh, vimpager for pager less and zless, vimcat for cat (if that's relevant) and run arch linux. see relevant lines from .zshrc below:

# emacs and stuff
alias e='TERM=xterm-256color emacsclient -t'
alias ec='emacsclient -c'
alias ed='emacs --daemon'
export TERM=xterm-256color

# vimpager
export PAGER='vimpager'
alias less=$PAGER 
alias zless=$PAGER
alias cat='TERM=xterm-256color vimcat'
alias vim='TERM=xterm-256color vim'
alias vi=vim

Should add 'projectile-rails-destroy'?

Sometimes, especially when generating model with wrong name. User may need 'undo' the action.
should add this functionality to perform rails destroy?

Cannot interact with rails when encounter a conflict

Below is output

Projectile Rails Compilation started at Fri Jan 23 14:11:28

bundle exec rails generate scaffold Fuck fuck:string
      invoke  active_record
      create    db/migrate/20150123061131_create_fucks.rb
      create    app/models/fuck.rb
      invoke    test_unit
      create      test/models/fuck_test.rb
      create      test/fixtures/fucks.yml
      invoke  resource_route
       route    resources :fucks
      invoke  scaffold_controller
      create    app/controllers/fucks_controller.rb
      invoke    slim
      create      app/views/fucks
      create      app/views/fucks/index.html.slim
      create      app/views/fucks/edit.html.slim
      create      app/views/fucks/show.html.slim
      create      app/views/fucks/new.html.slim
      create      app/views/fucks/_form.html.slim
      invoke    test_unit
      create      test/controllers/fucks_controller_test.rb
      invoke    helper
      create      app/helpers/fucks_helper.rb
      invoke      test_unit
      invoke    jbuilder
      create      app/views/fucks/index.json.jbuilder
      create      app/views/fucks/show.json.jbuilder
      invoke  assets
      invoke    coffee
      create      app/assets/javascripts/fucks.js.coffee
      invoke    scss
      create      app/assets/stylesheets/fucks.css.scss
    conflict    app/assets/stylesheets/scaffolds.css.scss                                                                 
      invoke  scss
  Overwrite /Users/1/Documents/Project/tiehkaiwoo/app/assets/stylesheets/scaffolds.css.scss? (enter "h" for help) [Ynaqdh] 

By changing second argument of compile to t resolves this issue.
But all the projectile-rails specific hooks won't run. (e. g. buttons link to file.)
I tried redefine projectile-rails-compilation-mode's parent mode to be comint-mode, the issue is still exist.

Any ideas?

Expanding API

Projectile-rails is fantastic! Bug free, in my experience, and with solid tests.

I would like to build off it, but many of its procedure require (interative). For instance, I would love a non-interactive version of this procedure: https://github.com/asok/projectile-rails/blob/master/projectile-rails.el#L288, to simply get a list of rails "resources"

The only way I can do it now is something like this

(projectile-rails-choices '(("app/controllers/" "/controllers/\\(.+\\)_controller\\.rb$")))))

Basically, I just cut-and-paste from you code. It would be cool, if I didn't have to duplicate such expressions.

Thoughts?

Debugging with pry

Can I switch *projectile-rails-server* on breakpoin such as binding.pry or byebug into inf-ruby mode like it rspec-mode does?

It work on inf-ruby-switch-from-compilation. Perhaps it will be better add tip in README?

How can I bind keys for running the default rake command?

I'm a newcomer to emacs, so sorry for the probably obvious question: I want to run the default task (my tests) via a key for projectile-rails-rake, but whenever I try to invoke it, I'm getting either a wrong-number-of-arguments or wrong types of arguments.

Can you point me in the right direction?

Thanks, I'm really enjoying the mode.

tramp password prompt doesn't work when projectile-rails is loaded.

If
(add-hook 'projectile-mode-hook 'projectile-rails-on)
is in my .emacs and I try to use tramp to find a file (via ssh for instance) which requires a password prompt, the prompt seems to be obscured. If I use pki with no password, tramp successfully finds the file.

Emacs seems like it's locked up when this happens, but if I mash C-g enough, I can break out and clean up the tramp connections.

This seems to happen whether I'm in a rails project or not. This is on emacs 24.3 with the latest (as of today) projectile-rails and the stock tramp (as well as the latest stable tramp).

To reproduce, ensure the following are in your emacs init:
(projectile-global-mode)
(add-hook 'projectile-mode-hook 'projectile-rails-on)
Then try to find a file on a remote server that requires authentication:
C-x C-f /ssh:USER@HOST:SOMEFILE
In my case, I see "Sending Password" and no indication that input is doing anything.

Then, when I remove "(add-hook 'projectile-mode-hook 'projectile-rails-on)" from my .emacs, this operation works as expected.

Copying functionality from rails.vim

I've looked at the rails.vim documentation what projectile-rails currently lacks is:
* :Eenvironment [{name}] Edit the config/environments file specified. With no
argument, defaults to editing config/application.rb
or config/environment.rb.

  • :Efixtures [{name}] Edit the fixtures for the given or current model. If
    an argument is given, it must be pluralized, like the
    final filename (this may change in the future). If
    omitted, the current model is pluralized. An optional
    extension can be given, to distinguish between YAML
    and CSV fixtures.
  • :Efunctionaltest [{name}]
    Edit the functional test or controller spec for the
    specified or current controller.

* :Einitializer [{name}] Edit the config/initializers file specified. With no
argument, defaults to editing config/routes.rb.

  • :Eintegrationtest [{name}]
    Edit the integration test, integration spec, or
    cucumber feature specified. With no argument,
    defaults to editing test/test_helper.rb.

* :Elayout [{name}] Edit the specified layout. Defaults to the layout for
the current controller, or the application layout if
that cannot be found. A new layout will be created if
an extension is given.

* :Elocale [{name}] Edit the config/locale file specified, optionally
adding a yml or rb extension if none is given. With
no argument, checks config/environment.rb for the
default locale.

* :Emailer [{name}] Edit the mailer specified. This looks in both
app/mailers for Rails 3 and app/models for older
versions of Rails but only tab completes the former.

  • :Etask [{name}] Edit the .rake file from lib/tasks for the specified
    name. If no argument is given, the application
    Rakefile is edited.
  • :Eunittest [{name}] Edit the unit test or model spec for the specified
    name or current model.

Which of them would be useful for you guys? What are your view points on that? I mean for :Eintegrationtest and :Efunctionaltest I just use projectile-rails-find-spec. Though of course I do not support Test::Unit yet, only rspec.

projectile-rails-find-current-spec dependency on `rspec-mode`

The problem with it is that when I'm in a fixture file and execute projectile-rails-find-current-spec, rspec-toggle-spec-and-target creates a new spec file for the fixture. Would you be interested in a pull request that implements it in projectile?

Ideally it should handle it like projectile-rails-find-current-view where if it find multiple matching specs it asks which one the users wants.

And it should also use projectile-rails-fixture-dirs to decide which test/ or spec/ to use, making projectile-rails-find-current-test obsolete.

Scroll buffer

On page refresh projectile-rails move point in current buffer, not in *projectile-rails-server*
And I got error:

error in process filter: smooth-scroll-up: End of buffer
error in process filter: End of buffer

Invalid function: projectile-rails-if-zeus

I'm using emacs 24.3.1 with cask installed (my full setup is at https://github.com/map7/emacs-config )

I've got a new Rails app and I've tried this on a project with and without zeus running and I get the same error when trying to run the console:

Projectile-Rails mode enabled
projectile-rails-console: Invalid function: projectile-rails-if-zeus

Can't change keymap-prefix

;; FIXME: this does not work!
(setq projectile-rails-keymap-prefix (kbd "C-c p C-r"))
;; or
(eval-after-load "projectile-rails"
  '(progn
     (define-key projectile-rails-mode-map (kbd "C-c p C-r") 'projectile-rails-keymap-prefix)
     ;; (setq projectile-rails-keymap-prefix (kbd "C-c p r"))
     ))

I tried upper two solutions. Both failed.

Rake/Rails Can't Find Spring

Whenever I run a Rake or Rails command, it always uses bundle exec instead of spring.

I see that rake.el and projectile-rails.el both MD5 the project dir and PID path to determine if Spring is running. However, they never seem to locate it.

  1. What can I do to troubleshoot the lookup of the PID file?
  2. Shouldn't there be an option to always use spring? Spring will spawn a server upon first launch. Or is this an avoided complexity due to processes vs shells and sub-shells?

Issue with rename-buffer-at-point

This mode overrides default key binding for rename file or buffer at point. I use this key binding quite seldom, but it takes me some time to figure out why it stops working.

Please add warning about in in the readme or so.

Doesn't work when rails dir != git dir

Hello,

I have a project that is structured differently than the classic rails app:

philippe@pv-desktop:~/work/project$ tree -d -L 2
.
├── apps
│   ├── nginx
│   └── rails
├── data
├── env
└── utils

Thus, projectile-rails-root is not the same as projectile-project-root and it fails... what do you reckon would be the easiest workaround/fix?

How to run server/console with rvm?

Hello,

Whenever I try to use the server/console I have this:

-*- mode: projectile-rails-server; default-directory: "~/work/someproject/" -*-
Projectile Rails Server started at Tue Jun 10 10:21:02

bundle exec rails server
ERROR: RVM Ruby not used, run `rvm use ruby` first.

Projectile Rails Server exited abnormally with code 127 at Tue Jun 10 10:21:02

I did run rvm-activate-corresponding-ruby and robe-mode works correctly.

Can't create a new file

My steps:

  1. in controller file articles.rb
  2. press [C-c C-r V] to find corresponding views file. (I set prefix to [C-c C-r])
  3. helm raise candidates new.html.erb, edit.html.erb.
  4. I want to create a new views file: create.html.erb.
  5. Input the filename, then I got this error by toggling option debug-on-error.
Debugger entered--Lisp error: (wrong-type-argument stringp nil)
  expand-file-name(nil "/home/stardiviner/Code/learning/Ruby/Ruby on Rails/Tutorial/blog/")
  projectile-expand-root(nil)
  projectile-rails-goto-file(nil)
  projectile-rails-find-current-view()
  funcall-interactively(projectile-rails-find-current-view)
  call-interactively(projectile-rails-find-current-view nil nil)
  command-execute(projectile-rails-find-current-view)

I also tested in other cases:

  • find-current
    • view
  • stylesheet
  • find (not current)
    All of them does not work.

Version for melpa-stable?

It would be nice if there were a version of projectile-rails for melpa-stable (it definitely seems stable enough based on my usage). All that would be needed would be to make a version tag. In addition, projectile-rails currently requires projectile "1.0.0-alpha", which doesn't yet exist (so it's only compatible with the melpa version); it would be nice if it would be usable with the melpa-stable version of projectile (currently 0.12.0).

projectile-rails-rake has problem on ivy.

I set projectile-completion-system 'ivy.
Found projectile-rails-rake has problem:
Here is the debug output after toggle debug-on-error:

Debugger entered--Lisp error: (void-function ivy)
  ivy("Rake task: " ("about" "assets:clean[keep]" "assets:clobber" "assets:environment" "assets:precompile" "cache_digests:dependencies" "cache_digests:nested_dependencies" "db:_dump" "db:abort_if_pending_migrations" "db:charset" "db:collation" "db:create" "db:create:all" "db:drop" "db:drop:all" "db:fixtures:identify" "db:fixtures:load" "db:forward" "db:load_config" "db:migrate" "db:migrate:down" "db:migrate:redo" "db:migrate:reset" "db:migrate:status" "db:migrate:up" "db:purge" "db:purge:all" "db:reset" "db:rollback" "db:schema:cache:clear" "db:schema:cache:dump" "db:schema:dump" "db:schema:load" "db:schema:load_if_ruby" "db:seed" "db:setup" "db:structure:dump" "db:structure:load" "db:structure:load_if_sql" "db:test:clone" "db:test:clone_schema" "db:test:clone_structure" "db:test:deprecated" "db:test:load" "db:test:load_schema" "db:test:load_structure" "db:test:prepare" "db:test:purge" "db:version" "default" ...))
  rake--completing-read("Rake task: " ("about" "assets:clean[keep]" "assets:clobber" "assets:environment" "assets:precompile" "cache_digests:dependencies" "cache_digests:nested_dependencies" "db:_dump" "db:abort_if_pending_migrations" "db:charset" "db:collation" "db:create" "db:create:all" "db:drop" "db:drop:all" "db:fixtures:identify" "db:fixtures:load" "db:forward" "db:load_config" "db:migrate" "db:migrate:down" "db:migrate:redo" "db:migrate:reset" "db:migrate:status" "db:migrate:up" "db:purge" "db:purge:all" "db:reset" "db:rollback" "db:schema:cache:clear" "db:schema:cache:dump" "db:schema:dump" "db:schema:load" "db:schema:load_if_ruby" "db:seed" "db:setup" "db:structure:dump" "db:structure:load" "db:structure:load_if_sql" "db:test:clone" "db:test:clone_schema" "db:test:clone_structure" "db:test:deprecated" "db:test:load" "db:test:load_schema" "db:test:load_structure" "db:test:prepare" "db:test:purge" "db:version" "default" ...))
  rake--read-task("/home/stardiviner/Code/learning/Ruby/Rails/learning/todo_list/" 0)
  rake(nil projectile-rails-compilation-mode)
  projectile-rails-rake(nil)
  call-interactively(projectile-rails-rake nil nil)

remove clutter when looking for specific type of file

If I'm looking for a controller, it's going to be _controller.rb ... If it's a model, it'll have .rb ... Can we remove the extensions for the ruby files, and whatever prefixes are unnecessary, like _spec, _controller?

This is the behavior of rails.vim and I used to like it, FWIW.

void-function projectile-rails-on

Followed the instruction and got following error when visiting file in rails project:

 Error in post-command-hook (projectile-global-mode-check-buffers): (void-function projectile-rails-on)

How to stop rails server

I have started the rails server using C-c r R. But how to stop it? Killing the buffer did not stop it completely or restart because of some changes made to initializers?

Thanks.

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.