Hi
I am trying to experiment on an open source application application .
when i run
$ rake db:create
Following is the stacktrace
rake aborted!
uninitialized constant Cucumber
/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:443:in `load_missing_constant'
/usr/lib/ruby/gems/1.8/gems/activesupport-...
I am learning how to write test cases using Rspec. I have a simple Post Comments Scaffold where a Post can have many Comments. I am testing this using Rspec. How should i go about checking for Post :has_many :comments. Should I stub Post.comments method and then check this with by returning a mock object of array of comment objects? Is t...
I have a model called MyContainer, which :has_many MyObjects.
I want to delete all the MyObjects in the container without having to delete the MyContainer.
My model does have :dependent => :destroy, however I don't want to have to delete and re-create the object because it is slower.
Something like this does not work:
@obj = MyContai...
Has anyone managed to make the example at http://railscasts.com/episodes/196-nested-model-form-part-1 work?
When I followed through the sample, it never saves any question nor the answer to the database but it manages to create a new survey entry.
I am using:
Rails 2.3.5
ruby 1.8.6 (2008-08-11 patchlevel 287) [i386-mswin32]
nifty-ge...
How to test the following example?
class Post < ActiveRecord::Base
belongs_to :discussion
def after_save # or after_create
discussion.touch
end
end
EDIT: I have found a nicer way to write the code above.
class Post < ActiveRecord::Base
belongs_to :discussion, :touch => true
end
...
Hi All,
I am calling a ajax method to update a div. It contains links and functions which require java script files. But these methods and functions are not getting called properly as java script files are not getting included through ajax call. For example, i am trying to call a light box function, but it gets redirected to different p...
Hello people,
I have two models with a HABTM association, let´s say book and author.
class Book
has_and_belongs_to_many :authors
end
class Author
has_and_belongs_to_many :books
end
The author has a set of attributes (e.g. first-name,last-name,age) that can all be blank (see validation).
validates_length_of :first_name, :maximum...
In CakePHP, I can specify a prefix in my database configuration, f.e. "so_", so that every model looks for its table under this prefix.
Is something similar possible in Rails, too? That is, can several programs share one database?
...
I need to get the exact start and end dates (month, day and year) of a given year.
E.g., 2008
Jan. 1, 2008
Mar, 30, 2008
Any thoughts on how to do this?
array = [2007, 2008, 2009, 2010]
array.each do |a|
#code to get array of date for a (year)
end
...
I have a named_scope in rails that finds episodes by there directors given name
named_scope :director_given, lambda { |dr| {:joins => :director, :conditions => ['given = ?', dr]} }
It works great but I would like it to also work on substrings one the name. e.g. instead of having to search for 'Lucy' you could just search 'Lu'.
P.S....
I'm developing a Rails 2.3, Ruby 1.9.1 webapplication that does quite a bunch of calculation before each request. For every request it has to calculate a graph with 300 nodes and ~1000 edges. The graph and all its nodes, edges and other objects are initialized for every request (~2000 objects) - actually they are cloned from an uncalcula...
Hi everyboy,
I used to have PHP websites and using url rewriting on picture to have SEO friendly urls,
On php I had links like
/image/blablablabla-1234-blablabla
rewriting to:
/image/1234.jpg
by using a url rewrite rule on apache .htaccess file.
So I would like the structure /image/<text>-ID-<text> to return /image/<id>.jpg reguardl...
Hi,
I am using recaptcha in my RoR application, i have my public and private keys defined in the environment.rb. Whenever i try to validate the recaptcha value using
verify_recaptcha it always returns false
i went inside the code of verify_recaptcha and found out that i always get following error
"input error : error parsing input c...
Is there a way to change the minimum length for passwords with restful_authentication? Currently it's 6 characters and I need another value.
I've tried calling validates_length_of before and after Authentication::ByPassword like this
validates_length_of :password, :within => 4..40, :if => :password_required?
include Authentication::B...
Hi,
I have a named_scope in my model and want a different condition, based on the locale. On the development this code works perfect, after switching to production the named_scope doesn't work and I get every time the first condition ("de"). I think it's a caching problem?
I'm working with 2.3.5. and env settings out of the box.
named_...
Hello,
I'm building a rails app above couchdb and decided to try the couch_potato and simply_stored gems as they seem add a nice feature set above the rest api and put the couchdb development 'on the rails'.
From what I can see SimlyStored/Couch works above the couch_potato layer, so from my understanding, the basic couch_potato featur...
Hello, i have some problem with creating a function to my Rails app.
I want it to work like this:
str = "string here"
if str.within_range?(3..30)
puts "It's withing the range!"
end
To do that i added this into my application helper:
def within_range?(range)
if self.is_a?(String)
(range).include?(self.size)
elsif self.is_a?(In...
Hi all, it seems that when the blind down effect is used on an element with padding it looks a bit awkward. It seems to blind down too far and then jumps back. It's a very subtle thing but is really annoying.
I don't have an online example but if you go to the demo on github and give the element a padding-top or bottom with firebug or ...
I'm trying to create a <select> element using the collection_select method, but it seems that in order for the proper <option> to be selected, the identifier passed into collection_select needs to be an instance variable and not a local variable (this is happening in a partial).
So when I create a <select> for the categories of a produc...
I'm using the Refinery content management system with a the Portfolio plugin
see http://github.com/resolve/refinerycms
I wanted to create a title and description for images uploaded to
Refinery using Refinerycms-Portfolio
so far I have done the following;
added the columns to the images table;
$script/generate migration AddTitleToImage...