Git Product home page Git Product logo

Comments (10)

Silex avatar Silex commented on July 16, 2024

@asok: ping?

from projectile-rails.

asok avatar asok commented on July 16, 2024

@Silex sorry for not responding it seems that I've overlooked the notification for this issue.

So I guess under apps/rails you have your normal rails app, but you want ~/work/projects to be treated as the root? Maybe the easiest would be to overwrite projectile-rails-root function after loading the package? Something like this:

(eval-after-load 'projectile-rails
  (defun projectile-rails-root ()
    (projectile-project-root)))

from projectile-rails.

Silex avatar Silex commented on July 16, 2024

@asok: hum, no that's already what it does...

The problem is that all the functions like projectile-rails-find-controller just assume everything is under app/controllers in the projectile-project-root no matter what projectile-rails-root says.

Here's my attempt:

(defun projectile-rails-root ()
  "Returns rails root directory if this file is a part of a Rails application else nil"
  (ignore-errors
    (let ((root (projectile-project-root)))
      (concat root "app/rails"))))
Debugger entered--Lisp error: (file-error "Setting current directory" "No such file or directory" "/home/philippe/work/stvs/arqivis/app/controllers/")
  call-process("/bin/bash" nil t nil "-c" "git ls-files -zco --exclude-standard")
  apply(call-process "/bin/bash" nil t nil ("-c" "git ls-files -zco --exclude-standard"))
  process-file("/bin/bash" nil t nil "-c" "git ls-files -zco --exclude-standard")
  shell-command-to-string("git ls-files -zco --exclude-standard")
  projectile-files-via-ext-command("git ls-files -zco --exclude-standard")
  projectile-get-repo-files()
  projectile-dir-files-external("/home/philippe/work/stvs/arqivis/" "/home/philippe/work/stvs/arqivis/app/controllers/")
  projectile-dir-files("/home/philippe/work/stvs/arqivis/app/controllers/")
  projectile-rails-choices((("app/controllers/" "/controllers/\\(.+\\)_controller\\.rb$")))
  projectile-rails-find-controller()
  funcall-interactively(projectile-rails-find-controller)
  #<subr call-interactively>(projectile-rails-find-controller nil nil)
  ad-Advice-call-interactively(#<subr call-interactively> projectile-rails-find-controller nil nil)
  apply(ad-Advice-call-interactively #<subr call-interactively> (projectile-rails-find-controller nil nil))
  call-interactively(projectile-rails-find-controller nil nil)
  command-execute(projectile-rails-find-controller)

One possible workaround could be to tell projectile to consider Gemfile as another project within the git project... but that's a bit nasty.

from projectile-rails.

asok avatar asok commented on July 16, 2024

Maybe something like this:

modified   projectile-rails.el
@@ -326,6 +326,9 @@ Returns a hash table with keys being short names and values being relative paths
       (maphash (lambda (key value) (setq keys (cons key keys))) hash)
       keys)))

+(defun projectile-rails--append-root-suffix (dirs)
+  (--map (format "%s%s%s" (projectile-project-root) "apps/rails/" it) dirs))
+
 (defmacro projectile-rails-find-resource (prompt dirs &optional newfile-template)
   "Presents files from DIRS to the user using `projectile-completing-read'.

@@ -333,7 +336,7 @@ If users chooses a non existant file and NEWFILE-TEMPLATE is not nil
 it will use that variable to interpolate the name for the new file.
 NEWFILE-TEMPLATE will be the argument for `s-lex-format'.
 The bound variable is \"filename\"."
-  `(let* ((choices (projectile-rails-choices ,dirs))
+  `(let* ((choices (projectile-rails-choices (projectile-rails--append-root-suffix ,dirs)))
           (filename (or
                      (projectile-completing-read ,prompt (projectile-rails-hash-keys choices))
                      (user-error "The completion system you're using does not allow inputting arbitrary value.")))

Though I haven't tested it. Probably you would have to change it slightly because dirs is a list of lists. So you would have to run map twice on it. (BTW I don't recall why I made it so :) )
Let me know how it worked out.

from projectile-rails.

Silex avatar Silex commented on July 16, 2024

Hum, yeah I guess that would work... it's pretty hacky tho.

I can't help but feel that there is an unsolved problem reguarding projectile-rails-root because it's basically pretty useless at the moment.

IMHO there needs to be some refactoring so the detection of "rails project" is done in a better way.

Right now it works like this:

  • projectile-rails-root: checks if projectile-project-root contains config/environment.rb.
  • All the finders ignore projectile-rails-root and use projectile-dir-files which uses projectile-project-root.

I think it'd be better if it behaved like this:

  • projectile-rails-root: use projectile-locate-dominating-file to find which directory contains config/environment.rb
  • Refactor everything so the finders use projectile-rails-root (probably as simple as writing a projectile-rails-dir-files function which does the right thing)

I'll see if I can hack something.

from projectile-rails.

asok avatar asok commented on July 16, 2024

@Silex I've added you as a collaborator to the project

from projectile-rails.

Silex avatar Silex commented on July 16, 2024

๐Ÿ‘ ๐Ÿ˜„

from projectile-rails.

Silex avatar Silex commented on July 16, 2024

Ok, I started the work in another branch, you can look at the diff with https://github.com/asok/projectile-rails/compare/rails-root-improvements?expand=1

from projectile-rails.

asok avatar asok commented on July 16, 2024

Ok cool. Please make a PR. Travis should run it and we should see the result the tests. Unfortunately recently some of them fail, I was too lazy fix them. But if the same will fail as for the master branch we can merge it.

from projectile-rails.

Silex avatar Silex commented on July 16, 2024

Alright, it's not done tho. It more or less works except I couldn't do the final steps (still have to fix projectile-rails-goto-file and friends)

from projectile-rails.

Related Issues (20)

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.