Is it generally better practice (and why) to validate attributes in the model or in the database definition?
For (a trivial) example:
In the user model:
validates_presence_of :name
versus in the migration:
t.string :name, :null => false
On the one hand, including it in the database seems more of a guarantee against any type of b...
I'm trying to get Ruby on Rails setup on my new eeeubuntu install and I think I'm having some issues installing RVM properly.
I installed GIT, and that went well. I installed RVM and in the install it told me to add
if [[ -s /home/derek/.rvm/scripts/rvm ]] ; then source /home/derek/.rvm/scripts/rvm ; fi
To the end of .bashrc
Which I ...
I've got a ruby script that opens a connection to Apple's push server and sends all the pending notifications. I can't see any reason why, but I get broken pipe errors when Apple disconnects my script. I've written my script to accomodate this happening, but I would rather just find out why it's happening so I can avoid it in the first p...
The following code:
map.resources :users, :has_many => :items
Could be written like this in a block:
map.resources :users do |user|
user.resources :items
end
How could I write the following code in a block?
map.resources :users, :member => { :start => :post }
Also, where could I find documentation on writing routes in blocks?...
Am I crazy, or is it a bad idea to keep my SMTP username and password for ActionMailer in the actual (development/production) config file? It seems like I should store it an encrypted place, or at the very minimum, exclude it from my Mercurial pushes.
Right now, I'm just removing the password from my source file before performing a push...
Hey all,
I get the following error message when I try to perform an update in flash builder 4 beta:
[RPC Fault faultString="Error #1090: XML parser failure: element is malformed." faultCode="Client.CouldNotDecode" faultDetail="null"]
at mx.rpc.http::AbstractOperation/http://www.adobe.com/2006/flex/mx/internal::processResult()[E:\dev\gu...
I have content management system application that uses a polymorphic tree table as the core of its arrangement. I've come into a problem where once the tree grows quite large, and because we have quite a few different modules (about 25), just doing :include => :instance doesn't cut the mustard. Instance is the name of our polymorphic rel...
There is always a degree of black magic when it comes to Rails and I can't find the documentation to help me figure out this one. What redirect_to does is clearly straight forward. In fact, this question isn't even directly related to, but an argument I see passed to redirect_to often and can't understand where that argument is coming fr...
My rails server seems to break after installing the facebooker plugin. Any suggestions on fixing this would be great.
I'm using rails 3.0.0.beta and facebooker.
Here are the steps and the error that I'm seeing:
$ rails -v
Rails 3.0.0.beta
$ rails break; cd break
$ ./script/rails plugin install git://github.com/mmangino/facebooker.git...
I'm having trouble getting the reports_as_sparkline plugin working on PostgreSQL (it works fine on SQLite).
Here's an example error:
>> Annotation.creations_report
ActiveRecord::StatementInvalid: PGError: ERROR: operator does not exist: ` character varying
LINE 1: ... grouping = E'day' AND aggregation = E'count' AND `condition...
...
I have been using Deprec with Slicehost for a bit now but it seems like development isn't that active anymore.
What do you use for automating most of the deployment steps for Rails these days? I'm using Slicehost.
...
Hello, I am using the Single Access Token from authlogic to sync data from a MS Access Database to a Rails App. Because I sort of think that the URL sort of exposes the single access token, I am uneasy about extended use. I have heard that if one uses basic http authentication, HTTPS is really important for security. Is my case similar?
...
Hi,
I have a hash like,
object = { :type => 'book', :name => 'RoR', :price => 33 }
OR
object = { :type => 'wig', :name => 'Elvis-Style', :price => 40, :color => 'black' }
The problem is that keys in above hash may be different all the time or even increase and decrease depending upon the object type.
What I want to do generate XM...
I have a list of items (<ul> containing <li>'s) which I want to limit by height.
Let's say I have the following code:
<ul>
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
<li>Item 4</li>
<li>Item 5</li>
<li>Item 6</li>
</ul>
This will display as such:
Item 1
Item 2
Item 3
Item 4
Item 5
Item 6
I would like it to di...
I am running a Jcarousel and I want to add a.active to the current pagination option. I have seen other posts around about this same thing.
/**
* We use the initCallback callback
* to assign functionality to the controls
*/
function mycarousel_initCallback(carousel) {
jQuery('.jcarousel-control a').bind('cli...
I'm trying to deploy a small rails app using sqlite3, but I keep getting the following exception: SQLite3::SQLException: unable to open database file. Permissions have been set to:
-rwxrwxrwx 1 www-data root 208896 Mar 2 11:26 joboversigt.db
I can read (select) from the database with no problem, put writing isn't working
...
I'm trying to create a drop-down select box for a polymorphic association with ActiveScaffold.
I have:
class Award
belongs_to :sponsorship, :polymorphic => :true
end
class Organization
has_many :awards, :as => :sponsorship
end
class Individual
has_many :awards, :as => :sponsorship
end
While trying to create a select drop-down...
I need to create a tab delimited ASCII file from a table (Hits) in my DB. I can already export this table into a CSV file. What's the best way to go about doing this? Is there a way to easily create this in rails?
...
I am trying to create a new environment(build) for using it with hudson...
Am doing this because i didn't want to mix up my test databases with hudson test database..
Thanks in advance..
...
I have a rails application running over Postgres.
I have two servers: one for testing and the other for production.
Very often I need to clone the production DB on the test server.
The command I'm runnig via Vlad is:
rake RAILS_ENV='test_server' db:drop db:create
The problem I'm having is that I receive the following error:
Active...