I have a model, Person, with the following association:
has_many :distributions
accepts_nested_attributes_for :distributions, :allow_destroy => true
validate :distributions_must_total_100
The custom validation currently fails when it shouldn't -- when some of the validations have been marked for destruction -- because they still sho...
Now about 2 weeks into learning Ruby and Rails, I've found myself using the File class a lot for things like File.join, File.open, etc. Then I bumped into a need for File.copy only to find out that no such method exists. A little more looking uncovered Rails' FileUtils class and now I'm a little confused.
There are differences, of cours...
I've been reading up on a bit of STI Inheritence examples for Rails,
While it looks like it would suit my needs (User role/types inheriting from a base class of user). It seems like it doesn't handle a user having multiple roles too well. Particularly because it relies on a type field in the database.
Is there a quick and easy work arou...
Here's the relevant controller code:
if @song.update_attributes(params[:song])
respond_to do |format|
format.js {
render :action => 'success'
}
end
else
Here's what's in success.js.erb:
$("#song_updated_at").val( "<%= escape_javascript @song.updated_at %>" )
Here's the error I get:
ActionView::TemplateError ($_ v...
I am using rails 2.3.3 and ruby 1.9.1.
I am trying to render a view that includes a partial. In the partial i output a field of a model that is encoded in UTF8.
This fails with
ActionView::TemplateError (incompatible character encodings: ASCII-8BIT and UTF-8) on line #248 of app/views/movie/show.html.erb:
245: <!-- Coloumn right | s...
I have a model which uses acts-as-tree. For example:
class CartoonCharacter < ActiveRecord::Base
acts_as_tree
end
Acts as tree has these associations:
class ActsAsTree
belongs_to :parent
has_many :children
end
From script/console I am building my tree, saving nothing until the entire tree is constructed. The trouble I am ha...
I have just started learning ruby on rails and I have encountered code like below:
class Post < ActiveRecord::Base
validates_presence_of :title
belongs_to :user
end
There are two method calls inside the class body.
I have had a hard time finding any ruby documentation that
describes how method calls from within a body of a class (...
I've loaded the cucumber.vim files into ftplugin and the other directories per instructions, but I don't understand the ftplugin syntax enough to figure out how to get the full benefits.
From what I can tell, the plugin is supposed to be able to jump between step definitions and feature files, but I can't figure out what's wrong with my...
I am trying to add a calendar date select when a user presses a button. The following code works in my partial.html.erb file:
<%= calendar_date_select_tag "due_date[#{i}]",nil,:popup=>:force,:year_range => 0.years.ago..5.years.from_now,:style=>'width:120px;'%>
But when I try to add the same code in my javascript as:
var cell3 = new_r...
My application uses Ruby on Rails and store session_id in _myapp_session.
But when I include my GWT module in a Rails view, it responds that it can only see one cookie (_auth_token) but there is no _myapp_session. I collect all cookie names with Cookies.getCookieNames()
How do I solve this?
...
I am a newbie to Rails. I have simply scaffolded a small model. The model has a field called category. Now I want to filter the entries on the index page by category.
<% form_for @domain do |f| %>
<p>
Domain:
<%= f.select(:Domain,%w{ LifeStyle Automobiles FoodAndBeverage Health IT Telecom EntertainmentAndCelebrity Education BankingInv...
Which is the Recommended File Extension for rails view pages(2.3.2)
1.RHTML
2.html.erb
any significance in this.
...
Is there any way to generate model with the name rack.
...
I'm just trying out cache_money gem on an existing app and getting this error:
NoMethodError (You have a nil object when you didn't expect it!
The error occurred while evaluating nil.repository)
I think I have my memached server configured properly.
I'm using Rails 2.2.2
EDIT:
Stack trace:
NoMethodError (You have a nil object when ...
Hello all,
in my current rails application I have a bunch of named routes defined to deal with the static content like this:
map.with_options :controller => 'static_content' do |static|
static.imprint 'imprint', :action => 'imprint'
static.menu1 'menu1', :action => 'menu1'
static.menu1_sub1 'menu1/sub1', :action =...
Hey folks,
I just cannot install Ruby on my CentOS (which is also hosting a cPanel).
sudo yum install ruby ruby-devel ruby-irb ruby-rdoc ruby-ri
audit_log_user_command(): Connection refused
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
base: mirror.sov.uk.goscomb.net
updates: mirror.sov.uk.goscomb.net
...
Hello;
I installed the paperclip plugin and was able to use it locally. When I configured it to work with amazon S3 I keep getting the NoSuchBucket (The specified bucket does not exist) error. Paperclip documentation states that the bucket will be created if it doesn't exist but clearly
something is going wrong in my case.
I first insa...
Hello,
I was searching for a plugin/gem solution to extend the native rails i18n for storing my translations into my database. Maybe I used the wrong search terms, but all I found was the information, that changing the backend IS actually possible and this blog entry which descripes how to write my own backend.
It's hard to imagine, th...
I am trying to add some instance variables in helpers like the following:
module ApplicationHelper
def title=(title)
@title = title
end
def title
@title
end
end
and when I assign title in views/pages/index.html.erb like the following:
<% title = 'Listing Pages' %>
and try to show it in the views/layouts/application.html.e...
Rails and ActiveRecord do a perfectly nice job of dealing with what I would consider exceedingly simple queries that deal with a single model. I now have a situation where I need to do something slightly more complex - but still trivial - and I don't know how to do it.
I have a User that has_many :images. Each Image has_many :thumbnails...