I have a CRUD controller for a model.
Doing resources :foo allows me to route on /foo/:id, etc. for calling actions.
I want add a route for a translation of 'foo' in another language. Let's say 'toto'.
So I want all the /toto/:id, etc., routes to act exactly like the /foo/:id, etc., routes.
How may I achieve that?
...
Hi
Since migrating a project to rails 3, haml errors are not very descriptive..
All we're getting in the logs is a generic nil object error.
For instance in rails 2.3.8 when the indentation in a haml file was incorrect we'd get an error message pointing to the file and approx line.
However now in rails 3 we just get
NoMethodError (Y...
I'm trying out 'shoulda' on top of rspec (rails 3) with the following spec:
require 'spec_helper'
describe Article do
should "be true" do
assert true
end
end
and it fails with
/Users/jeppe/.rvm/gems/ruby-1.8.7-p302/gems/rspec-expectations-2.0.0.beta.20/lib/rspec/expectations/handler.rb:11:in `handle_matcher': undefined method...
I have an ActiveRecord model Eventwith a datetime column starts_at. I would like to present a form, where date and time for starts_at are chosen separately (e.g. "23-10-2010" for date and "18:00" for time). These fields should be backed by the single column starts_at, and validations should preferably be against starts_at, too.
I can of...
Im trying to make my rails application (2.3.5) to run on Ruby 1.9, I've this function that make some transformations on a string:
def replace_special_chars(downcase = true)
if downcase
string = self.downcase
else
string = self
end
string.gsub! /á|ã|à|ä|â/, 'a'
string.gsub! /é|è|ë|ê/, 'e'
string.gsub! /í|ì|ï|î/, 'i'
string.gsub! /ó|...
Hi,
I want use always thin when I start my rails server in development mode.
By default it webrick to use. So I add thin in my Gemfile
gem 'thin', :group => 'development'
Now If I want use it to launch my server in development mode I mandatory define it.
bundle exec rails s thin
If I don't define it, it's always use webrick. So H...
I am having a Property model that should contain multiple values (just Strings). With Rails/ActiveRecord it seems that I have to create a new model (and a new table) for those values (like PropertyValue). As every one of those values just stores one String the PropertyValue only need one attribute (like value).
I don't like that idea cau...
hi,
i'm running ruby 1.8.7 with rails3. after installing mysql2 (successful) I want to create the dbs, but the following error occurs:
noname:addressDB clemens$ rake db:create
(in /.../addressDB)
rake aborted!
undefined method `errno' for #<Mysql2::Error:0x1024f21f0>
(See full trace by running task with --trace)
noname:addressDB cleme...
I'm writing an rspec scenario thats failing with:
(#<User:0x1056904f0>).update_attributes(#<RSpec::Mocks::ArgumentMatchers::AnyArgMatcher:0x105623648>)
expected: 1 time
received: 0 times
users_controller_spec.rb:
describe "Authenticated examples" do
before(:each) do
activate_authlogic
@user = Factory.create(:vali...
I am new to Rails. I came from a Codeigniter background. I am having a hard time finding resources on Rails 3.0 for beginners. I read my new Rails book but am still confused about a few things.
How do I include my libraries or helpers into a controller? Do I use an "include" or "require"?
The 2nd question is how do I dynamically load p...
This is a pure syntactical question. I'm very new to RSpec.
I basically want to write something on the lines of this erroring line :
controller.stub!(:current_user(:update_attributes => false))
Anyone know how to properly write that?
RSpec's default looks like this :
User.stub(:find) { mock_user(:update_attributes => false) }
...
It seems that on development machines (like on the Macbook), if we use bundle install --deployment, all the gems will be installed into the vendor/bundle folder and it just use more disk space if we have multiple Rails 3 projects (some project just for testing Rails 3). If it is not --deployment, then the gems will be in the "generic" f...
in config/routes.rb:
resources posts do
resources comments
end
resources pictures do
resources comments
end
I would like to allow for more things to be commented on as well.
I'm currently using mongoid (mongomapper isn't as compatible with rails3 yet as I would like), and comments are an embedded resource (mongoid can't yet ha...
The things described in the formal documentation are a bit complicated.
Does it merely add the following line to .bundle/config
BUNDLE_PATH: vendor/bundle
and then perform a bundle install, and that's it? (install will then install all the gems into vendor/bundle)
Then when the application runs, it will look for the gems in this pa...
I have an interesting conundrum. I have a table of programs that has_many install_validations that have many install_validation_reactions (don't ask!). I set the program model to accepts_nested_attributes_for :install_validations, :allow_destroy => true, and the same between the install_validations and install_validation_reactions. Built...
I'm creating a basic message board app with Rails 3. I want posts to be created with UJS/jQuery (submit the post with AJAX and clear the form). I thought this would be simple but I'm getting this error:
Rendered posts/create.js.erb (64.5ms)
Completed in 1771ms
ActionView::Template::Error (undefined local variable or method `posts' fo...
I'm trying to use Ruby's csv module to import the records contained in a csv file to my local table in a Ruby on Rails 3 application.
The table was created through the creation of model Movie.
Here is what I've been executing in console:
require 'csv'
CSV.foreach('public/uploads/VideoTitles2.csv') do |row|
record = Movie.new(
...
I think the 5 sets of files or folder the Rails 3's Bundler create are:
Gemfile
Gemfile.lock
.bundle/config
vendor/bundle
vendor/cache
Is there any more? For each of them, should they be added to the repository? Gemfile and Gemfile.lock, I think so, because that's what let everybody use the same version of gems. For .bundle/config...
I18n fallback is loaded:
I18n::Backend::Simple.send(:include, I18n::Backend::Fallbacks)
Any idea now to temporary disable it? I have forms, where I want to edit various language versions, and with fallback I am getting fields with default language, if given translation is yet not present.
...
Hello Stack,
I'm migrating the majority of my application to the admin namespace and while there are lots of guides related to this, I still can't manage. I've been primarily following this answer, along with any results Google brings up (they all tend to agree). Could somebody please tell me what I'm doing wrong so I don't lose any mor...