Do I build Ruby documentation in Ubuntu ? Or should I simply move past this? - ruby-on-rails

While navigating through http://installfest.railsbridge.org/installfest/linux I made it to step 4 and instead of rvm install 2.3 I used rvm install 2.4.4 in the Ubuntu command prompt and everything ran fine. Once output was finished, the last two lines said: Install of ruby-2.4.4 - #complete
Ruby was built without documentation, to build it run: rvm docs generate-ri What do you fine people think? Build or not? The above link is meant to be part of an installation process for The Odin Project, which is just a free online web dev course if that helps put things into perspective.

I use RubyMine. When I'm curious about a method, such as render, I put the text caret on it and hit Control+B. RubyMine takes me to the method's definition, where I can read the comment which generates that documentation.
I always build Ruby and Gems with full documentation, and I never bother to read their output...

Related

How do I setup the ruby SDK in IntelliJ IDEA?

I've been using this guide
Whenever I go to import the module I get this screen:
I used the following file path, maybe this is whats wrong?
/usr/local/Cellar/ruby-build/20160130/share/ruby-build/2.3.0
And got this error:
I'd appreciate any ideas anyone might have, i've been trying get this working all night!
I ran into this problem with Intellij IDEA 2020.2. It took a while to resolve because the Intellij documentation seems to be missing one critical piece.
When you first open a project in IDEA, it assumes all your code is part of a Java module. With that module in place you cannot set a Ruby SDK at the module level. There's no option to do because the existing module is configured as Java.
Here's a screenshot of my example project with the default Java module. Notice the icon is a folder with a blue rectangle in the lower, right corner.
Here's what I had to do.
Open the Project Structure dialog (File | Project Structure).
In the Modules settings, highlight the top-level project module and click the delete button (looks like a minus sign).
Click the plus sign to add a new module.
From the pop-up click "New Module".
In the "New Module" pop-up select Ruby and the correct Module SDK (e.g. rbenv: 2.5.0)
When you are prompted to enter the Module name, Content root, and Module file location, make sure the directories are set to your project's root. When I entered the module name it appended the name to the project's root directory which is probably not what you want.
Once you've done that the module should appear with a Ruby icon on it and the rest should work as documented here: https://www.jetbrains.com/help/idea/configuring-language-interpreter.html
Here's a screenshot of my new Ruby module. You can see the Ruby icon replaced the blue rectangle.
I hope this saves you some time!
In order to set Ruby SDK for your project in IDEA you need to go to File | Project Structure | Project Settings and set project and module SDK.
Olivia is correct, the "Project Structure..." (Mac shortcut Cmd+;) is the dialog for configuring the IDE to use different ruby installations.
The first requirement is that the ruby manager (chruby, rbenv, rvm) is configured properly.
Another concern is exactly where and how jetbrains expects the ruby installation to be organized. I wonder if Intellij is compatible with the way ruby-install lays out ruby? That's the one I used with chruby. I could not make it work.
The posted url to Opening Rails projects in IntelliJ IDEA helped me feel the most confidence that we are on the right track. :)
At the time, I was failing to get Intellij configured due to fact the gem files were not seen by the IDE. All but about 4 gems in my project's Gemfile was being highlighted as having an SDK problem.
To end this, I stopped using chruby and ruby-install. I am not blaming chruby, however I could not make the chruby system work properly with the IDE. It worked fine in the shell. Note, I am a previous user of rvm and rbenv. Switching back to rbenv, now. Note that I've also stopped using ruby-build directly.
Instead, I built the first ruby version directly from rbenv:
rbenv install 2.3.1
Next, I created the .ruby-version file in the root of my rails project directory by running:
rbenv local 2.3.1
To help with any confusion regarding the minimum support needed in the shell startup scripts. Do not alter PATH at all. Place the following in your shell startup script system, whatever that may be:
# rbenv config in my .bash_profile
# --------------------------------
if which rbenv > /dev/null; then
eval "$(rbenv init -)";
fi
With the prerequisites out of the way...
I recommend doing the project import in the same way described in the jetbrains tutorial Opening Rails projects in IntelliJ IDEA.
In the first screenshot from thesowismine, I see two dialogs for different purposes that are simultaneously open. Unless I am mistaken, one of those dialogs should have received its info and closed before going forward, at least during the wizard-like process. Perhaps this was done and that dialog was reloaded later?
In any event, that is not where the Ruby SDK is associated to a Rails project. The screenshot indicates the User is browsing around the brew Cellar, which may indicate two things.
Ruby was installed with a brew install <version> command; I installed ruby by calling the rbenv ecosystem.
That particular dialog is for informing the IDE about the Rails project folder, not the Ruby kit.
Assuming the first dialog is provided with the root directory of the Rails app and next is clicked; then in the second dialog, I change nothing and click next. The 3rd dialog is where I confirm the project directory is correct and I can assign a more elaborate name (which is displayed in the IDE's project menu). Clicking next may prompt you to write over the ".idea/" directory. Say yes. The next dialog confirms that sources were found. Click next. Now Frameworks begin to be detected assuming the Ruby Manager is setup correctly. Click Finish.
Now, goto the "Project Structure..." dialog to set the SDK.
Before or after setting the SDK, go to the the project directory of your Rails project, run:
gem install bundle
bundle install
This will install all the gems your project requires including the rails gem, as presumably it is listed in your Gemfile.
Note that gemsets do not come up, here. In this config, the set of gems are associated to a particular Ruby installation. Bundler is your friend.
Languages & Frameworks > Ruby SDK and Gems
I was able to solve this by doing:
Preferences | Plugins | Install JetBrains plugin

Do I Really need to install homebrew to install rails and why?

I hope this question is suitable for this forum, I'm still learning what's deemed fit and what isn't. Anyway here is my question, a lot of places seem to state I need to install homebrew on my mac to install rails, do I really need to and what benefits does it offer to do so and for the development environment?
This question is pretty bad but I remember when I started programming that I had a similar question, so here we go:
How do you install stuff on your computer? Obviously you use the Mac App Store if you want something from Apple, and if you want to install Chrome just go the Google Chrome website etc.
But when you want some kind of programmer tool, let's say a compiler. How do you install this? Either you go to their website, download a tarball with the source code, compile it from scratch and bind the necessary environment variables. Or you are unlucky and the compiler has a bunch of dependencies so you have to download them first.
Then some geniuses thought that "Oh damn, that's a pain", so instead they created so called package managers, so now when I want Rails on my computer, I just installed it through the "gem" ruby package/dependency manager.
So you can install rails through the command "gem" (just google "ruby gem") and you'll see what it is, but I advise you to if you want to have a nice development environment where it's easy to install and uninstall stuff, use brew or macports.

Dealing with a large c++ library in a Rails deployment

I have a Rails project that is going to be using OpenCV, and it depends on a certain version of it (2.4.6.1).
I'm looking for deployment advice. The Ubuntu opencv package is an earlier version and therefore not suitable.
I can see a number of possibilities, but I'm trying to think of what will work best.
Just write it up in a README and expect people to follow it: download this, apt-get that, etc...
Add opencv, tagged at the version we need, as a git subtree, and include a Rake task to build it.
Write a script to download and compile the needed code.
Something else ?
None of them seem all that great, to tell the truth.
Can your application be made to work with OpenCV 2.4.2? That is available in Ubuntu 13.04, and you could request it be backported to 12.04. If not, you could update the source package to 2.4.6.1 (which would require learning about debian packaging but might not be too difficult since you would be modifying an existing package instead of starting from scratch), upload it to a PPA, and instruct your users on Ubuntu to install OpenCV from there. You could also package your rails application and put it in the PPA, which would make overall installation even easier.

New to vim - MAC OSX Mountain Lion

I am new to vim, and I just followed this setup tutorial, but something went wrong. I am a ruby developer and I am not getting a a ruby highlighting syntax. I have installed janus, before with pathogen I had syntax highlighting but not know.
Also I am using the solarized theme the guy suggested but there is no difference now (in color) between folders and files in my terminal when listing a directory.
Could somebody tell me if I can install pathogen with janus? WIll this break my vim?
Thanks!
Don't install anything (and don't install Janus).
Run $ vimtutor in your terminal. As many times as needed (and don't install Janus).
Once you feel ready to use Vim for day-to-day coding, install MacVim which is built with a better feature set than the default Vim. It comes with a CLI executable so you can use it in your terminal and in tmux (and don't install Janus).
Install the vim-ruby package for better, more up-to-date Ruby support (and don't install Janus).
Don't install Janus. This thing is a pile of crap that will make your life overly complicated, hook you on plugins that may or may not be the best for you needs and prevent you from actually learning Vim properly in exchange of an artificially flattened learning curve.
Decide for a plugin/runtimepath management solution (VAM, vundle or plain Pathogen) and choose your plugins yourself according to your needs (and don't install Janus).
If you have problems with Solarized, take a look at their issue tracker and their wiki. It is fragile and you need some work to set it up correctly (and… you know the rest).

virtual ruby development environment

I mainly do ruby on rails development on my machine but from time to time I end up using other laptops for RoR development. It would be nice if there was something (maybe shell?) which basically bring all the gems installed on my machine to some other machine without leaving any footprints. It's basically a really light VM without the OS stuff.
If it matters, I'm using a mac. Ideally I would like to keep that virtual environment in my dropbox and basically when I use some other machine, I would just get it from my dropbox and start coding and not have to worry about setting up the environment.
Similar to Jacob's answer, I'd recommend using RVM, but I'll expand on it. Here's some brainstorming ideas:
RVM stores its sandbox in your home directory at ~/.rvm. All Ruby instances, plus the associated gems will be stored there. It's a simple addition to the ~/.bashrc file in your Mac to initialize RVM so it's known by the shell when you log into the account. It's also a simple rm -rf ~/.rvm from the commandline to remove the RVM sandbox from the account, followed by removing the line from the ~/.bashrc.
So, basically, by setting up RVM correctly and installing your Ruby installation on one machine, you're 90% of the way to having it available for multiple machines.
I'm pretty sure Ruby will install without any dependencies on a current Mac OS using RVM, but there's a couple libraries that can improve the experience. After installing RVM, but before installing any Rubies, run rvm notes. That will show you what else to install. You'll need the current XCode to compile a Ruby, but only on the machine you do the compiling on. Once it's installed you should be able to move a RVM controlled Ruby around to other Macs by copying the ~/.rvm directory. So, not only would you have the gems, you could have a particular version, or versions, of Ruby, plus the associated gems, so your regression tests could work too.
If you use MacVim you could install it in ~/bin and have the GUI version. I haven't tried running it from there, but it seems like it'd work. You might need to create an alias from /Applications to the one in ~/bin for double-clicking.
MacVim comes with a shell script called mvim to launch it from the command-line. I have a bunch of softlinks to mine letting me call it from the command-line in various ways: gvim, and the gvim varients like gvimdiff and gview. You could do the same by adding ~/bin to your PATH and making the links locally in that dir to MacVim's mvim.
You could build a tarball of the vim config, vim installation and RVM sandbox, copy that to another Mac, expand it, add ~/bin to your PATH and append the needed RVM initialization line in ~/.bashrc, open a new command-line, and have your editor plus Ruby sandboxes.
It's a minor variation on how my Mac and Linux boxes are set up. I haven't tried bundling everything together, but, on Macs that are the same OS version, it should work.
Consider using rvm to manage different gem configurations. If you want you can store your rvm configurations in your dropbox (rather than in ~/.rvm, where they go by default) so that your gemsets are synced across machines.

Resources