If I want to have validation only on create, then I can do
validates_presence_of :password, :on => :create
but how do I say on create and update? I tried this but didn't work.
validates_presence_of :password, :on => [ :create, :update ]
Do I have to define the validation two times?
...
I have a SharePoint server. I am building an rails application which can interact with sharepoint server although this is not the primary goal of the application. I am planning to provide this as an advantage.
My target areas would be
1. Fetching available document repository from SharePoint
2. Add documents to sharepoint using Rails fr...
I am writing a web-based dev-console for Rails development. In one of my controller actions, I am calling Rake, but I am unable to capture any of the output that Rake generates. For example, here is some sample code, from the controller:
require 'rake'
require 'rake/rdoctask'
require 'rake/testtask'
require 'tasks/rails'
require 'string...
So Rails time stamping is great. I'm using it to add expires headers to all files that end in the 10 digit timestamp. Most of my images however are referenced in my CSS. Has anyone come across any method that allows for timestamps to be added to CSS referenced images, or some funky re-write rule that achieves this? I'd love for ALL i...
For example, if I have a user with an email address that needs validating on presense and format:
validates_presence_of :email_address, :message => "can't be blank"
validates_format_of :email_address, :with => /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i
If nothing is entered, how can I prevent both error messages appearing? I kn...
I have a Rails form for editing objects of a particular class. The labels on the form need to vary slightly depending on which particular object is being edited.
The obvious way to do this would be to add an instance method to the model objects to return the appropriate label for that object. However, this would appear to be putting pa...
Hi there,
A Ruby on Rails app will have access to a number of images and fonts. The images are components of a visual layout which will be stored separately as a set of rules. The rules specify document dimensions along with which images are used and where. The app needs to take these rules, fetch the images, and generate a PDF that ...
Can we have multi-level subdomain in Rails like this?
sub1.sub2.mysite.com
Imran
...
I have a plugin that must be loaded before resource_controller. The reason is that Resourcecontroller tries to load ApplicationController and it depends on the said plugin (and will fail to load if plugin's init.rb was not loaded yet).
The problem is that ResourceController comes from a gem and not a plugin.
Is there a way to load plug...
I ran sudo gem update earlier today and was thrilled to see it work, but at the end it failed.
Building native extensions. This could take a while...
ERROR: While executing gem ... (Gem::Installer::ExtensionBuildError)
ERROR: Failed to build gem native extension.
ruby extconf.rb update
can't find header files for ruby.
I don't ha...
I'm running some bizarre Postgres migration code from OpenCongress and I'm getting this error:
RuntimeError: ERROR C25001 MVACUUM cannot run inside a transaction block
Fxact.c L2649 RPreventTransactionChain: VACUUM FULL ANALYZE;
So I'd like to try running it without getting wrapped by a transaction.
...
I have User model, where user should be able to upload one picture as an avatar. But I don't really know how to implement this in correct REST way. I see two options
First I think of avatar as of member resource that belongs to user, so I add two actions to my Users Controller, one avatar for the upload form, and second action for handl...
I have a model called sites. A site will have several adjacent sites (and also be an adjacent site for other sites).
I am trying to determine how best to capture the list of adjacencies.
I have considered creating a text field in the site model and using serialize to store/retrieve the array of all of the adjacent sites. The problem wi...
I recently created a project skeleton with Edge Rails and installed rspec, rspec-rails and cucumber as plugins (git submodules). If I run:
$ script/generate
all I get is a list of built-in generators. The ones from the plugins don't show up. I installed the same plugins as gems and got the same result. Does anyone know why this is hap...
I'm attempting to post a json object to my server, however for whatever reason it doesn't show up in production.
In development params.inspect yields
({"format"=>"json", "body"=>"Wtf", "api_key"=>"xxx", "action"=>"comment", "item_id"=>"496", "controller"=>"api"})
And in production I get
({"format"=>"json", "action"=>"comment", "con...
Hello all,
I have been trying to convert my rails 2.2.2 app over to jQuery, and would like so without using jrails. The only reference material I can find on the subject is Railscasts Episode 136. Ryan goes over how to use jQuery to post a form and handle the response in a .js.erb file.
My questions is has anyone tried to use jQuery w...
Howdy,
We internationalized our site months ago, but forgot one part: The drop down where a user picks their timezone.
How do you translate the following line:
= f.time_zone_select :timezone, ActiveSupport::TimeZone.all
...
It's quite common in sites- you have a "demo" version with a guest account full of data/posts/comments that you can play with, and all the data is reset every few hours so users wont spam the demo site.
I thought to have another rails environment, "mysite_demo" and use a cron job to call rake to reset it's database every X hours, and po...
Hi!
I'd like to know if cocoa has a default way of storing data. If yes what is it? I mean like rails is by default using sqlite...
Also I'm searching for a tutorial on how to use it... Like get data and showing it into a listview, etc...
Thanks for your help!
...
I'm trying to assert that the last record did not get deleted in rails model unit test. I raise an exception if the record.count.one? is true. Initially there are two records.
Edited:
There is a user story that says you can delete the users.
You cannot delete the user that you are logged in with. (functional test)
You cannot delete the ...