New iMac - New Rails Environment - Dropbox - Permission Problem - ruby-on-rails

Ok, I just bought the new 27 inch iMac and I am trying get everything set up. I am new to rails and have been developing on my MacBook Pro and seem to be having some trouble sharing my applications. I use dropbox which allowed me to easily access the new files from my new iMac and therefore my rails applications but after installing rails, when I try to start the server for my app, I get:
-bash: script/server: Permission denied.
I am assuming this has to do with the app being protected but not sure what to do here.

It's not protected, I guess you lost the execution right while dropping your files.
Just do:
chmod +x script/server
You might consider something else for the transfer, like rsync instead of drop box.

Rather than sharing the entire application directory structure, I've found that the better solution is to share a git repo via dropbox and then clone it on each machine (I also have an iMac and MBP that I work on)
The problem with storing the app on Dropbox is that the logfiles and possibly sqlite database can chew up a lot of room. Nopt to mention that it's always good to use some sort of SCM (git being the most favored in the Rails community, but others should work fine too.)
I went through the steps to do this on another answer to another question.

Related

Ruby on Rails: is there an ideal app directory structure in Windows

Just a quick question from a Rails learner.
As I understand it, it is not necessary to place a new Rails app inside the directory where Ruby and Rails are installed.
But, is there an ideal place for apps? What are experienced developers using?
I ask this, because I may have misplaced a previous app, hidden somewhere deep in a directory structure; and, strange as it might seem to most of you, I cannot find where the older app is.
I have quite some problems searching in Windows 10; it is a nightmare, compared to how it was in Windows XP.
There isn't "standard", community agreed directory structure for Rails apps.
However, I noticed that many developers would create Projects folder within their "user home" directory (C:\Users\username in Windows and ~ in linux distro). I do the same and when I need to find some project I worked on 5 years ago, I don't think twice where to look for it. Obviously, that means you'd end up with a lot of project dirs in your Projects folder. So I move very old projects to my backup disk occasionally.
A quick note on Ruby/Rails. Rails projects are not like PHP. They are more like Java, when you run your application (as a separate process) and it stays in the memory running & serving user requests. In PHP you had to put your php files into your server's document directory so that server could parse and execute your scripts. So, with Rails projects you are not limited with where you put them.

Move RefineryCMS from Local to Production

We decided to try using RefineryCMS for our current project and have run into some issues.
We began the project in a local development environment. The deadline is very quickly approaching. At first, we tried to move the project into production using a DreamHost server. There were issues with the images (Refinery uses Dragonfly), where our database dump wasn't brining any images over (or thumbnails).
We have exhausted our resources and still can't find a solution to our problem. I've done research, asked in the Google group, emailed people, and asked in the chat - no one has answered yet.
So, does anyone here have any idea what is the best solution for moving a project over from a local development environment to production?
I am sure I can't be the only person who has run into this issue...
Thanks in advance.
In case someone arrives here with this same situation (as I did), my two cents:
I've successfully migrated between servers by dumping the database and copying public/system, so this is perfectly feasible and straightforward.
At first the images were not showing neither in the backend nor in the frontend, but after a couple of hours stuck I realized the problem was that I hadn't installed ImageMagick in the new server (huge facepalm).
A quick sudo apt-get install imagemagick solved the issue.
Of course, YMMV, but I hope that helps.
I'm not sure what version of RefineryCMS you are using, or how you configured it, but unless you chose to use Amazon S3 for uploads then your Dragonfly images and resources are being stored on the file system. So in addition to that database dump, you'll probably want to look in the public/system/ folder and copy everything in the images and resources folders up to the server too.

Is there a way for a ruby on rails app to support web-based upgrades like Wordpress does?

I've been using Wordpress for awhile, it's installed on my own server, and one of the features I most love about it is how every time there is a new version it alerts you within the app's web-based admin and with one click I can upgrade the app. I don't have to get anywhere near a console.
Personally I wouldn't mind updating manually, but I can see how this could significantly affect the adoption of a piece of software. I'm working on creating a full-featured ruby on rails forum software and I would love to figure out how to include this feature. Any ideas if this could be done with rails?
Could a rails app modify it's own files? If it did, would the server need to be restarted?
To complicate things further, what if the app was deployed from a repo. Could the rails app check in a commit of itself after updating?
Maybe packaging the core of the app as a gem would be simpler? Then maybe the upgrade would not actually modify the rails MVC stack (the rails app would just be super-basic), instead if the forum was all contained within a gem then all it has to do is trigger a 'gem update [name]'. If this occurred, I don't think the Gemfile would even need to be updated. Would a server restart even be required to load the updated gem?
Ideas or feedback on any of this?
Rails files can be modified and even deleted on production - in my case aplication is still working unchanged as all classes are cached in memory. It means Rails instances must be restarted to take new change.
I suppose WordPress is Perl via CGI and you just drop application into web directory to have it working immediately - same with updates - just overwrite files and Apache picks them up immediately.
In case of Rails is that you don't know target deployment architecture thus restarting application may not be trivial. E.g. with passenger I can just do touch tmp\restart.txt and then all instances are killed and started again. Some deployments may need init.d script restart invocation.
Maybe you could recommend or prepare a ready to use deployment model which supports autoupdate. In other cases users could do updates manually.

Ruby on Rails offline programming

I am going to be away from the internet for a few weeks and would still like to get a project done. What steps should I take to make sure I have access to the things I need (ruby and ROR) while I will be disconnected?
when offline, the following are hard to get:
gems
docs
rails expert blogs
stackoverflow ;-)
so,
gem install as much as you can
download all the railscasts
keep one or two rails book around
and find a place with internet wifi
and most importantly:
un-plug yourself 2 days before the real offline, that's called staging ;-)
If you use version control, make sure you can work offline. DVCS do this well, I've heard SVN can work offline if you have a local SVN server.
Running the Rails app on localhost will allow you to access it with your browser locally.
Apart from this it would also be nice to have documentation offline too. Download everything you can think of: Rails, Ruby, Shell, libs etc. Or use books.
Make sure you have local copies of any documentation you need (railsapi.com lets you download the Rails docs)
Make sure you have all the gems/plugins you need
This may not affect you, but it's bitten me before.
If you are using a javascript library such as jQuery, and are linking to Google's Hosted Libraries rather than a local one, you may find jQuery stops working when you are offline.
Download and link to a local copy before you go.
Get your app (in its current state) up and running on your laptop. Then shut off wireless and make sure it still goes. Don't just guess at what gems and things you'll need - make sure you see it actually run. Don't forget things like database engines and queuing servers. Then start guessing about other gems and items you might need.
Make sure that
gem server
will start up a webserver and let you browse the docs for all your installed gems.
Download every Ruby gem. All of them!
You never know when you'll need to extract EXIF data, or something.

Backing up my locally hosted rails apps in preparation for OS upgrade

I have some apps running on Heroku. I will be upgrading my OS in two weeks. The last time I upgraded though (6 months ago) I ran into some problems.
Here's what I did:
copied all my rails apps onto DVD
upgraded OS
transferred rails apps from DVD to new OS
Then, after setting up new SSH-keys I tried to push to some of my heroku apps and, whilst I can't remember the exact error message off-hand, it more or less amounted to "fatal exception the remote end hung up"
So I know that I'm doing something wrong here.
First of all, is there any need for me to be putting my heroku hosted rails apps onto DVD? Would I be better just pulling all my apps from their heroku repos once I've done the upgrade? What do others do here?
The reason I stuck them on DVD is because I tend to push a specific production branch to Heroku and sometimes omit large development files from it...
Secondly, was this problem caused by SSH keys? Should I have backed up the old keys and transferred them from my old OS to my new one too, or is Heroku perfectly happy to let you change OS's like that?
My solution in the end was to just create new heroku apps and reassign the custom domain names in heroku add-ons menu... I never actually though of pulling from the heroku repos as I tend to push a specific branch to heroku and that branch doesn't always have all the development files in it...
I realise that the error message I mentioned doesn't particularly help anyone but I didn't think to remember it 6 months ago. Any advice would be appreciated
PS - when I say upgrade, I mean full install of the new version with full format of the HDD.
One of the reasons for using a (D)VCS (Version Control System) is reproducibility (usually "reproducibility of builds", but here also the ability to reproduce a given state of a system versioned at a given time)
So it could be a good test to see if you have:
all your system properly committed
all the process to regenerate the extra content (if need be) you need from your restored data
Making a bundle of your repo (meaning dealing with only one file to backup somewhere else, DVD or otherwise) is a good start.
And regarding your "hung up" error message, if SSH is involved, that means you need also to save SSH keys (see comments) usually located under the user's homedir (as in ~/.ssh/authorized_key)

Resources