I am attempting to take a whack at creating my first Rails application template and I am running into a slight issue with the copy_file method.
First some background.... Apparently the Ruby OpenSSL package does not ship with a CA store, so any attempt to connect to an HTTPS service will fail out of the box. The way around this(for Rails 3 apps) is to add the line OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE to the top of your config/environment.rb file. I need to do this on the fly in my template so I can install jQuery.
So I have that all figured out, my general thought is to:
Make a backup of my config/environment.rb file.
Prepend the data to original
Run the jquery:install --ui task
Restore the original config/environment.rb file.
See my template Gist, Lines 25..34 is the relevant section.
So all of that works until step #4 which fails with Error: Could not find "env.orig" in any of your source paths on line #31.
This is VERY perplexing to me because line #28 works, I can see the env.orig file on disk, so why won't the reverse work?
What am I doing wrong?
Update 1:
After looking at the Thor source thor\actions.rb it became clear that Thor uses different paths (not your current project path) for the source and destination. Furthermore my copy was actually not working, it was actually coping the ERB template file, not the already generated file.
After a breather it occurred to me use the right tool for the job so now I have: run 'cp environment.rb environment.~' and run 'mv environment.~ environment.rb' which works just fine. I am fairly certain this would not work on a windows box without the unix tools installed, but I can live with that. Does anyone have a better way?
See my Update for a Why, but the solution was to use the right tool for the job so now I have: run 'cp environment.rb environment.~' and run 'mv environment.~ environment.rb' which works just fine. I am fairly certain this would not work on a windows box without the unix tools installed, but I can live with that.
Related
Issue
I am using xray-rails gem in a rails app and want it to open rubymine to the correct file when I click it in the browser. It was unclear how to configure this. xray-rails gem uses open3 to open the file in the editor.
Solution
Prerequisite: Follow the instructions for setting up rubymine to be callable from the commandline found in Running RubyMine as a Diff or Merge Command Line Tool
NOTE: This is also a handy use of rubymine, allowing it to perform diffs between files. Nice bonus for researching a solution to my problem.
Create ~/.xrayconfig with content...
:editor: mine
NOTE: mine is the name of the script created in the prerequisite steps. If you named your script something different, use that name in place of mine.
Now when you start xray-rails in your browser and click, the corresponding file will open in rubymine.
As the title says, how to use luadoc in ubuntu/linux? I generated documentation in windows using batch file but no success in ubuntu. Any ideas?
luadoc
Usage: /usr/bin/luadoc [options|files]
Generate documentation from files. Available options are:
-d path output directory path
-t path template directory path
-h, --help print this help and exit
--noindexpage do not generate global index page
--nofiles do not generate documentation for files
--nomodules do not generate documentation for modules
--doclet doclet_module doclet module to generate output
--taglet taglet_module taglet module to parse input code
-q, --quiet suppress all normal output
-v, --version print version information
First off, I have little experience with Luadoc, but a lot of experience with Ubuntu and Lua, so I'm basing all my points off of that knowledge and a quick install that I've just done of luadoc. Luadoc, as far as I can see, is a Lua library (so can also be used in Lua scripts as well as bash). To make documentation (in bash), you just run
luadoc file.lua
(where file is the name of your file that you want to create documentation for)
The options -d and -t are there to choose where you want to put the file and what template you want to use (which I have no clue about, I'm afraid :P). For example (for -d):
luadoc file.lua -d ~/Docs
As far as I can see, there is little else to explain about the actual options (as your code snippet explains what they do well enough).
Now, looking at the errors you obtained when running (lua5.1: ... could not open "index.html" for writing), I'd suggest a few things. One, if you compiled the source code, then you may have made a mistake somewhere, such as not installing dependencies (which I'd be surprised about, because otherwise you wouldn't have been able to make it at all). If you did, you could try getting it from the repos with
sudo apt-get install luadoc
which will install the dependencies too. This is probably the problem, as my working copy of luadoc runs fine from /usr/bin with the command
./luadoc
which means that your luadoc is odd, or you're doing something funny (which I cannot work out from what you've said). I presume that you have lua5.1 installed (considering the errors), so it's not to do with that.
My advice to you is to try running
luadoc file.lua
in the directory of file.lua with any old lua file (although preferably one with at least a little data in) and see if it generates an index.html in the same folder (don't change the directory with -d, for testing purposes). If that DOESN'T work, then reinstall it from the repos with apt-get. If doing that and trying luadoc file.lua doesn't work, then reply with the errors, as something bigger is going wrong (probably).
Hi I am trying to install the emacs rails reloaded mode from https://github.com/dima-exe/emacs-rails-reloaded.
As per the directions I have cloned the repo and added the lines to my .emacs file. However it asks for byte compiling by -
Next bytecompile, press [M-x] and type rails/bytecompile.
However I cant find that function, what do I do ?
Note that you should restart Emacs between the steps
After that add bellow code in your the .emacs file:
(setq load-path (cons (expand-file-name "~/.emacs.d/rails-reloaded")
load-path))
(require 'rails-autoload)
and
Next bytecompile, press [M-x] and type rails/bytecompile.
Also, before restarting, make sure that you have changed "~/.emacs.d/rails-reloaded" to the actual path where the file rails-autoload.el lives. If you cloned the git repository, that path name should almost certainly end in emacs-rails-reloaded (and not just rails-reloaded).
If that path is incorrect, Emacs will report an error when it tries to execute (require 'rails-autoload). If it is correct, M-x rails/bytecompile should work.
I am having a problem with the ExecJS in that it is unable to locate a required Runtime. I am using Windows, and I have both Windows CScript and Node.js installed on my computer, but neither of these guys are being invoked.
As a result, I am unable to run any rails task that involves this (I cannot even load my rake list in RubyMine to call actions such as db:create to create my databases from a fresh project.)
I am capable of accessing both csript and node from the command line, and I have checked my environment variables and their proper file locations are in the PATH. There's something else ruining my ability to use ExecJS. Has anyone else had a similar experience where you have had all of the right stuff, but something is still going wrong?
When Ruby spawns child process to invoke CScript or Node, it will use the same rules that allow cmd.exe execute them from the command line.
But, sometimes, stuff in your registry or your environment variables can affect this process.
At RubyInstaller project we collected a series of troubleshooting items that could possible be the culprit.
Please check that COMSPEC environment variable is set to use cmd.exe and nothing like TCC/LE or other stuff.
C:\>SET COMSPEC
Also, check that your registry do not contain an AutoRun key, which will also affect Ruby.
C:\>REG QUERY "HKCU\Software\Microsoft\Command Processor"
C:\>REG QUERY "HKLM\Software\Microsoft\Command Processor"
If you see a key AutoRun in one of the above commands, that means something is setup to automatically execute everytime a new cmd.exe is started, which is bad for some cases.
Please follow the instructions in the Troubleshooting page on how to remove it.
This also affects gem installation that requires compilation, but if is not failing for you then the problem might be something else.
Hope that helps.
I was having similar problems, my basic skeleton app wouldn't run despite having Node.js installed, and then trying therubyracer gem. Finally I decided to use my troubleshooting mantra with windows, "When in doubt, run as admin". So I ran my rails cmd as an admin and it worked fine after that.
I am relatively new to dealing with command line issues, compiling programs, and UNIX. Coming from a PHP background, I just fired off MAMP and never worried about this kind of stuff.
I am diving into Rails, and running into some issues. I tried to create a .bash_profile in my home directory to create some shortcuts for myself. I added /usr/local/git/bin to my .profile file, but it seems to have no effect on my PATH variable inside a new terminal window (i.e. it only lasts the session).
The .bash_profile seemed to persist across logins, but once I had that setup, Rails stopped working as expected! I would run rails server in my application's root directory, and Rails would create a new app called 'server' with another directory tree inside my existing app. It does this even with an empty .bash_profile. But I delete the .bash_profile, and everything works like normal.
I am in over my head here - I have very little understanding of how this all works. Any advice on where to look? Or am I missing something obvious?
Post what you added to your .bash_profile. To pre-pend something to your path the syntax is:
export PATH=/usr/local/bin:$PATH
to append you swap the "/usr/local/bin" and $PATH
export PATH=$PATH:/usr/local/bin
After you make changes to your .bash_profile you can make them available in the current terminal session by running source .bash_profile. Then if you run echo $PATH you can see the updated PATH. You should try running rails --version in your different configurations to see if the version is changing. That may account for your odd behavior.
also checkout:
path-helper as extend PATH is sooo 2010