This Sessions Article is one of the better explanations and tutorials for using and operating sessions in a rails environment. I recommend giving it a read if you're going to be using sessions are are unsure you are using them correctly.
The author of the upcoming LiveCD that is poised to make installing Ruby on Rails for Linux users easier then ever is taking suggistions for what else to pack onto his CD before launch.
You can check out the RailsLiveCD site to find out when it will go live! It currently has the following on it already:
jEdit, RadRails, Subversion, MySQL, PostgreSql, SQLite and a lot of the useful gems already installed.
You can contact Brian Ketelson the creator with your suggestions through the ruby-forum.com.
This Ruby on Rails cheat sheet is a reference guide for RubyOnRailsBlog.com that will be continuosly updated and improved as new features are added to rails and new cheat sheet tips are added to the guide. It is a collection from the one of the very best guides, apis and source snippets that are concise that i’ve found. I’ve fixed errors and added highlighting to it and it is a mirror of the one found on nanorails site plus my own changes. New updates will be posted to this post under Recent Updates.
I recently was asked to look at an app where none of the css flash generated errors were being displayed. Low and behold the culprit was something very simple in the syntax involving ruby symbols.
flash['notice'] = "Section Created Successfully"
flash[:notice] = 'Section was successfully created.'
In some apps (some may argue most) session management is a critical aspect for performance and control of the system. From a sysadmin point of view it doesnt make a lot of sense to let a session stay connected forever since it will hog resources that could be put elsewhere.
So here is a way to expire sessions that become inactive in rails:
Some apps are designed where a user might sign up and be emailed a password. Here is the source code to allow for simple random password generatin.
It can also be used to change a users password if they request a new one due to forgetting the previous one:
This is all too common of faq in rails help channels and on mailing lists so it mine as well have some examples here too! Stick this in your user.rb model:
I am doing a permissions page for a project where I know that I can get all of the employees in the system (@employee.find(:all)) or get all the employees for the selected project.
How can I get a list of all the employees in the system and have a check box that states if they are associated with the current project or not?
This is just one way of doing this and its very simple once you see it:
Create this and use this methed:
You're using apache with fastcgi and you can access the "you're running rails" page at the but can't get to any of my controllers at , getting 500 errors instead.
In environment.rb set the following at the bottom:
ActionController::AbstractRequest.relativeurlroot = '/myrailsapp'
If that fails, I recommend trying it with mongrel webserver which has been known to fix whis problem for many.