open rails app from github in c9 IDE - ruby-on-rails

How can I open my rails application using google cloud9 cloud service. https://ide.c9.io IDE? What steps do I need to take? I have already copied and pasted application folder in IDE but when I run "bundle exec rails server -b $IP -p $PORT" it doesn't show anything.

I have been using c9 for quite a long time.
This is how to start(assuming you already checked out the code :))..
1. open new terminal
2. run /bin/bash --login
3. rvm use 2.2.2#myapp ---if using rvm
4. sudo /etc/init.d/postgresql start -- start postgres server if using
if you still dont have rails ,install using Ruby version manager AKA rvm..its very easy.
Now run..rails s -b $IP -p $PORT.
So when you server has started successfully,hit the application on the browser using...https://<your-workspace-name>-<your username for git>.c9users.io/..
for me its like...geophotos-mike1011.c9users.io
you may also click top right button Preview ...to preview your app inside your window.
Moreover,you can customise your app setting to be public/private and many more things to do..if you are a premium user :)
Hope it helps.

When starting a new workspace, you have an option to clone from a github repository, there is a box that states Clone from Git or Mecurial URL. Simply fill in the appropriate url from your git repo, choose ruby on rails for the template, and you should be good to go.

Firstly, one of the things you need to note is to add your shh github fingerprint to c9, which will enable you to push to GitHub from c9 afterwards. c9 should put you through the necessary step.
Secondly, follow RailsCasts Tutorial on how to contribute to open source http://railscasts.com/episodes/300-contributing-to-open-source.
I think that's about all you need to make your problem solved.

Related

Rails 5: How Do I Set Up a Merge Tool to use for rails app:update?

I'm upgrading a rails 5.2.4.1 app to rails 6. There are a few config files I want to merge instead of manually adding information from a copy of the old file.
The first time I entered m to merge the file I got the following message.
Please specify merge tool to `THOR_MERGE` env.
I did a search and found this blog post. The folder that this person found after Googling does not exist on my Mac computer.
FileMerge doesn't exist and DiffMerge is very old. I haven't found any information about using one with rails app:update.
What Mac merge tools are currently used that I can set the env var THOR_MERGE to?
Stumbled upon this answer searching for the same thing.
You can launch vscode diff tool by setting the THOR_MERGE env variable as follows:
THOR_MERGE="code -d $1 $2"
This is assuming you have code in your PATH, which you can setup by following the instructions here.
It seems that XCode includes /usr/bin/opendiff, which is a binary that launches FileMerge.app. So I was able to:THOR_MERGE=opendiff rails app:update
RubyMine can also be used as the merge tool. To make that work on my macOS Monterey system, I created a new Bash script at /usr/local/bin/rubymine-merge (based in part on the rubymine script provided by JetBrains Toolbox) with the following code:
#!/usr/bin/env bash
declare -- wait="-W"
bundle exec rubocop --server -A "$1"
open -na "$HOME/Library/Application Support/JetBrains/Toolbox/apps/RubyMine/ch-0/222.3739.56/RubyMine 2022.2 EAP.app/Contents/MacOS/rubymine" $wait --args merge "$2" "$1" "$2"
After this, I was able to invoke the Rails update script as follows:
THOR_MERGE=rubymine-merge bin/rails app:update
This is working as of RubyMine 2022.2.1 in mid-August of 2022.
The Rails update script seems to require that the merge tool behave as if it had received a --wait parameter, because after the last merge the script deletes all temporary files. Passing --wait as a command-line parameter seems problematic with the 2022.2 version of the command-line script, so I hard-coded the -W on line 3.
I also inserted a call to rubocop on line 5 so that the proposed changes from the Rails app:update script would already be aligned with the standards for this project. Skip that part if it's not meeting your needs. I had to use bundle exec rubocop instead of bin/rubocop because the Rails app:update script is not always running in the context of the root directory of your project.
It is suboptimal for this script be separate from the /usr/local/bin/rubymine script that is generated by JetBrains Toolbox. Every time a new version of RubyMine is installed, the path to the actual RubyMine application can change.
Simple Solution:
THOR_MERGE=kdiff3 rails app:update
or use opendiff / meld / kdiff etc.
Credit to #pduey (thanks).

Redmine plugin creation - Could not find generator 'redmine_plugin'

I run Redmine 3.4 with Rails (5.2.0) and Docker 18.03.1-ce on Ubuntu 16.04 Xenial (which is new for me), following this GitHub repository: https://github.com/sameersbn/docker-redmine
I create my Rails app in the same folder where the docker-compose.yml has been created, and cd to it.
Then I have the exact same problem than described in this Redmine post (http://www.redmine.org/boards/3/topics/48309?r=48507#message-48507): when I try the command rails generate redmine_plugin Plug_test, this two error messages appear:
Running via Spring preloader in process 32109
Could not find generator 'redmine_plugin'
So I try the commands that Keith suggested, and running the generate command again, the Spring error message disappear, but the generate command still doesn't work (Could not find generator 'redmine_plugin').
Any idea what to do? I don't know if I'm going in the right direction.
Thanks a lot for your help.
well simple problem, you're running command from outside of your redmine app directory, you need to go into your redmine app directory, after that you can run rails generate redmine_plugin Plugin_test from there
As Ravi mentioned above, you need to go into your redmine app directory instead of your rails app directory.
Or, maybe you can exec plugin generate command via docker run command.
# e.g. In case plugin name is “myplugin"
docker run --name=redmine -it --rm \
--volume=/srv/docker/redmine/redmine:/home/redmine/data \
sameersbn/redmine:3.4.4-2 \
app:rails generate redmine_plugin myplugin
If this works fine, plugin directory named “myplugin” will be generated under /srv/docker/redmine/redmine/plugins/ directory.
Personally, I think, you had batter not use docker to create and development Redmine’s plugin, especially if you are not familiar with Redmine and Docker so much.
I hope this would be any help.

Making Fedena a Windows Service Failed

I successfully installed Fedena on Windows using this tutorial:
http://en.wikibooks.org/wiki/Fedena/Installation
The problem is that each time I start windows, I need to run the command ruby script/server so that I can access the project locally. I tried making Fedena a Windows Service that starts automatically by following the steps mentioned in the tutorial, but it seems that it didn't work.
Making a Windows Service
If you want to run Fedena as a Windows Service (which automatically starts), do the following commands:
Open the Ruby Command prompt and go to your Fedena Installation director //do they mean by this C:/Fedena?
Install a Gem:
gem install win32-service
Install a Gem:
gem install mongrel_service
Run the command:
mongrel_rails service::install -N Fedena -c C:\FEDENA -p 3001 -e production
(Replace C:\FEDENA with whatever your Fedena installation Directory is.) You may also wish to change the port from 3001 to 80 so when entering the address from other computers, it is not required that you enter a port.
Go to windows search at the start menu, type:
services.msc
Look for service named 'Fedena' and set it to automatic
Restart your computer and see if the fedena start automatically. Always make sure that your server is running.
Any ideas what could be the problem?
Right after Fedena is configured, the start of the application is via console which should stay open for all the times if we want the application to be up and running. But quite often will get closed (human error, server down etc) and the application will go down.
The same applies if the server is rebooted/bounced and all over again.
So here is the solution if you don't want to go over this hassle:
Download http://nssm.cc/download/?page=download
Unpack it (lets say C:\NSSM)
Create a batch file ( lets say C:\Fedena\StartFedena.bat)
Edit the batch file ( right click on the bat file and click Edit)
Past the following code (change the paths accordingly)
********************************** (without the stars and this comment)
cd \
cd Fedena
mongrel_rails start -e production
Note: If you want to start it as development mode remove -e production from the last line
Open CMD
Type cd\
Type cd NSSM
depending on the system type: "cd win32" ot "cd win64"
9.Type in the cmd : "nssm install"
A modal window will pop-up
Click Browse
Navigate to the location where the batch file is and select it;
Leave options empty
Service name "Fedena"
Install Service
Go to "Services" (usually under Control Panel\System and Security\Administrative Tools)
Start Services
You should find service named "Fedena"
Start Service
Navigate to http://example.com:3000 and Fedena should be up
The service should be already set as automatic so if the server is restarted Fedena will come up automatically.
If you need to bounce the application just restart the Fedena Service.
That is,
Thank you

git doesn't work. I get "'git' is not recognized as ..."

I am trying to run this line out of http://docs.heroku.com/quickstart
git init
But I get
How do I get around this problem?
You need to install git on windows first, and then use the GIT bash shell. Here is the site for GIT on windows http://code.google.com/p/msysgit/
Just install that, open GIT Bash, navigate back to that directory and run that command again.
Make sure you did all the prerequisites on that page.
Did you install git? http://code.google.com/p/msysgit/
If so, make sure the location of the executable is in your PATH variable.
This site may help too:
http://kylecordes.com/2008/git-windows-go
i will suggest you to use tortoisegit , a git for window. But yet , develop rails in window is suffering , why don't you just dual boot your computer to linux and window ?

ruby script/plugin discover RuntimeError [duplicate]

The firewall I'm behind is running Microsoft ISA server in NTLM-only mode. Hash anyone have success getting their Ruby gems to install/update via Ruby SSPI gem or other method?
... or am I just being lazy?
Note: rubysspi-1.2.4 does not work.
This also works for "igem", part of the IronRuby project
For the Windows OS, I used Fiddler to work around the issue.
Install/Run Fiddler from www.fiddler2.com
Run gem:
$ gem install --http-proxy http://localhost:8888 $gem_name
I wasn't able to get mine working from the command-line switch but I have been able to do it just by setting my HTTP_PROXY environment variable. (Note that case seems to be important). I have a batch file that has a line like this in it:
SET HTTP_PROXY=http://%USER%:%PASSWORD%#%SERVER%:%PORT%
I set the four referenced variables before I get to this line obviously. As an example if my username is "wolfbyte", my password is "secret" and my proxy is called "pigsy" and operates on port 8080:
SET HTTP_PROXY=http://wolfbyte:secret#pigsy:8080
You might want to be careful how you manage that because it stores your password in plain text in the machine's session but I don't think it should be too much of an issue.
This totally worked:
gem install --http-proxy http://COMPANY.PROXY.ADDRESS $gem_name
I've been using cntlm (http://cntlm.sourceforge.net/) at work. Configuration is very similar to ntlmaps.
gem install --http-proxy http://localhost:3128 _name_of_gem_
Works great, and also allows me to connect my Ubuntu box to the ISA proxy.
Check out http://cntlm.wiki.sourceforge.net/ for more information
I tried some of these solutions, and none of them worked. I finally found a solution that works for me:
gem install -p http://proxy_ip:proxy_port rails
using the -p parameter to pass the proxy. I'm using Gem version 1.9.1.
Create a .gemrc file (either in /etc/gemrc or ~/.gemrc or for example with chef gem in /opt/chef/embedded/etc/gemrc) containing:
http_proxy: http://proxy:3128
Then you can gem install as usual.
This solved my problem perfectly:
gem install -p http://proxy_ip:proxy_port compass
You might need to add your user name and password to it:
gem install -p http://[username]:[password]#proxy_ip:proxy_port compass
If you are having problems getting authenticated through your proxy, be sure to set the environment variables in exactly the format below:
set HTTP_PROXY=some.proxy.com
set HTTP_PROXY_USER=user
set HTTP_PROXY_PASS=password
The user:password# syntax doesn't seem to work and there are also some badly named environment variables floating around on Stack Overflow and various forum posts.
Also be aware that it can take a while for your gems to start downloading. At first I thought it wasn't working but with a bit of patience they started downloading as expected.
Quick answer : Add proxy configuration with parameter for both install/update
gem install --http-proxy http://host:port/ package_name
gem update --http-proxy http://host:port/ package_name
I tried all the above solutions, however none of them worked. If you're on linux/macOS i highly suggest using tsocks over an ssh tunnel. What you need in order to get this setup working is a machine where you can log in via ssh, and in addition to that a programm called tsocks installed.
The idea here is to create a dynamic tunnel via SSH (a socks5 proxy). We then configure tsocks to use this tunnel and to start our applications, in this case:
tsocks gem install ...
or to account for rails 3.0:
tsocks bundle install
A more detailed guide can be found under:
http://blog.byscripts.info/2011/04/bypass-a-proxy-with-ssh-tunnel-and-tsocks-under-ubuntu/
Despite being written for Ubuntu the procedure should be applicable for all Unix based machines. An alternative to tsocks for Windows is FreeCap (http://www.freecap.ru/eng/). A viable SSH client on windows is called putty.
Posts abound regarding this topic, and to help others save hours of trying different solutions, here is the final result of my hours of tinkering.
The three solutions around the internet at the moment are:
rubysspi
apserver
cntlm
rubysspi only works from a Windows machine, AFAIK, as it relies on the Win32Api library. So if you are on a Windows box trying to run through a proxy, this is the solution for you. If you are on a Linux distro, you're out of luck.
apserver seems to be a dead project. The link listed in the posts I've seen lead to 404 page on sourceforge. I search for "apserver" on sourceforge returns nothing.
The sourceforge link for cntlm that I've seen redirects to http://cntlm.awk.cz/, but that times out. A search on sourceforge turns up this link, which does work: http://sourceforge.net/projects/cntlm/
After downloading and configuring cntlm I have managed to install a gem through the proxy, so this seems to be the best solution for Linux distros.
A workaround is to install http://web.archive.org/web/20060913093359/http://apserver.sourceforge.net:80/ on your local machine, configure it and run gems through this proxy.
Install: Just download apserver 097 (and not the experimental 098!) and unpack.
Configure: Edit the server.cfg file and put the values for your MS proxy in PARENT_PROXY and PARENT_PROXY_PORT. Enter the values for DOMAIN and USER. Leave PASSWORD blank (nothing after the colon) – you will be prompted when launching it.
Run apserver: cd aps097; python main.py
Run Gems: gem install—http-proxy http://localhost:5865/ library
I am working behind a proxy and just installed SASS by downloading directly from http://rubygems.org.
I then ran sudo gem install [path/to/downloaded/gem/file]. I cannot say this will work for all gems, but it may help some people.
This worked for me in a Windows box:
set HTTP_PROXY=http://server:port
set HTTP_PROXY_USER=username
set HTTP_PROXY_PASS=userparssword
set HTTPS_PROXY=http://server:port
set HTTPS_PROXY_USER=username
set HTTPS_PROXY_PASS=userpassword
I have a batch file with these lines that I use to set environment values when I need it.
The trick, in my case, was HTTPS_PROXY sets. Without them, I always got a 407 proxy authentication error.
If you are on a *nix system, use this:
export http_proxy=http://${proxy.host}:${port}
export https_proxy=http://${proxy.host}:${port}
and then try:
gem install ${gem_name}
rubysspi-1.3.1 worked for me on Windows 7, using the instructions from this page:
http://www.stuartellis.eu/articles/installing-ruby/
If you want to use SOCKS5 proxy, you may try rubygems-socksproxy https://github.com/gussan/rubygems-socksproxy.
It works for me on OSX 10.9.3.
If behind a proxy, you can navigate to Ruby downloads, click on Download, which will download the specified update ( or Gem ) to a desired location.
Next, via Ruby command line, navigate to the downloaded location by using : pushd [directory]
eg : pushd D:\Setups
then run the following command: gem install [update name] --local
eg: gem install rubygems-update --local.
Tested on Windows 7 with Ruby update version 2.4.1.
To check use following command : ruby -v
Rather than editing batch files (which you may have to do for other Ruby gems, e.g. Bundler), it's probably better to do this once, and do it properly.
On Windows, behind my corporate proxy, all I had to do was add the HTTP_PROXY environment variable to my system.
Start -> right click Computer -> Properties
Choose "Advanced System Settings"
Click Advanced -> Environment Variables
Create a new System variable named "HTTP_PROXY", and set the Value to your proxy server
Reboot or log out and back in again
Depending on your authentication requirements, the HTTP_PROXY value can be as simple as:
http://proxy-server-name
Or more complex as others have pointed out
http://username:password#proxy-server-name:port-number
for anyone tunnelling with SSH; you can create a version of the gem command that uses SOCKS proxy:
Install socksify with gem install socksify (you'll need to be able to do this step without proxy, at least)
Copy your existing gem exe
cp $(command which gem) /usr/local/bin/proxy_gem
Open it in your favourite editor and add this at the top (after the shebang)
require 'socksify'
if ENV['SOCKS_PROXY']
require 'socksify'
host, port = ENV['SOCKS_PROXY'].split(':')
TCPSocket.socks_server = host || 'localhost'
TCPSocket.socks_port = port.to_i || 1080
end
Set up your tunnel
ssh -D 8123 -f -C -q -N user#proxy
Run your gem command with proxy_gem
SOCKS_PROXY=localhost:8123 proxy_gem push mygem

Resources