eschulte / rinari

Rinari Is Not A Rails IDE (it is an Emacs minor mode for Rails)
http://rinari.rubyforge.org
GNU General Public License v3.0
412 stars 68 forks source link

Fixed invalid value is set to missing value in database.yml #88

Closed erw7 closed 9 years ago

erw7 commented 9 years ago

file-name-nondirectory return empty string if FILENAME is ending with a slash, So changed to delete the last slash before call file-name-nondirectory.

Changed to set an appropriate value when adapter was sqlite.

purcell commented 9 years ago

Thanks. I committed a slightly different version of this fix in 8f75d2e.

erw7 commented 9 years ago

Thanks. but I think next code is better.

(set (make-local-variable 'sql-database) (or (cdr (assoc "database" database-alist))
                                             (when (string-match "sqlite" adapter)
                                                  (concat "db/" environment ".sqlite3"))
                                             (concat (file-name-nondirectory (rinari-root))
                                                     "_" environment)))
(when
    (and
     (string-match "sqlite" adapter)
     (not (string-match "^"\\(^/\\|[[:alpha:]]:\\(/\\|\\\\\\)\\)"" sql-database)))
  (setq sql-database (expand-file-name sql-database (rinari-root))))

I was going to send the other pull request for append rinari-root when adapter was sqlite.

And next change has been missing.

(concat (file-name-nondirectory (directory-file-name (rinari-root)))
 "_" environment)
purcell commented 9 years ago

Done. The filename regexp isn't necessary, because expand-file-name understands canonical paths:

(expand-file-name "/foo/bar" "/tmp")

gives

"/foo/bar"
purcell commented 9 years ago

Thanks for all your help with this!

erw7 commented 9 years ago

Hmmm. Thanks for your quick work.