I have attribute name of model Person.
I want to use html-form with fields: first_name and surname:
<%= f.text_field first_name%>
<%= f.text_field surname%>
And I want to compose these virtual attributes to model attribute name.
What's the best way to do it?
I tried to use composed_of, but failed...
class Person < ActiveRecord::Ba...
Had a working app with Rails 3.0.0beta4 and just updated to the RC. Getting a new strange error. For some reason when I try to:
<%= link_to "test", user %>
The user is routed as resources :users yet it complains about no route for "action => destroy" despite I'm not even trying to link to destroy:
ActionController::RoutingError...
To set the stage, I'm using rails 3 and I have these tables and relationships:
user has_many lists
list has_many tasks
task has_many stints
I would like to build a query that allows me to select all of the current users stints, and to have the list.id available as an attribute on each stint in the result. I would need to rename list.i...
I have a HABTM relationship on one of my models. I'm using formtastic for my forms. On a new action when choosing to output my column (HABTM) as check_boxes I see all my options appear, however they are all checked on by default. Ideally I want them to not be selected on a new action. When I uncheck a few options and save them, I will se...
I have two classes:
class User < ActiveRecord::Base
:has_one :foo
end
class Foo < ActiveRecord::Base
:belongs_to :user
end
The Foo is optional.
I created the following routing:
resources :users do
resources :foo
end
Which results in the following routes:
GET /users/:user_id/foo(.:format) {:controller=>"foo...
I am trying to install vote-fu into my rails 3 project.
The documentation ( for rails 2 ) says to install it into my environments.rb file as so..
config.gem "peteonrails-vote_fu", :lib => 'vote_fu', :source => 'http://gems.github.com'
How could I convert that to rails 3 for the Gemfile?
...
I was getting 0.5 reqs/s on the front page of my rails app (a very simple, mostly static page that made a couple of database calls, but nothing that WEBrick said took longer than 0.8 ms), served with thin. I added ruby-prof profiling tools to my ApplicationController via the instructions at Dan Mange's blog and dumped the call graph to s...
Hello !
I'm trying to use jeditable with my rails 3 apps. I would like to edit some fields inline.
Actually it's working on my client side but the data isn't updated in my app.
Could you take a look? Thanks in advance!
my view:
<dt>Overview :</dt>
<dd class="edit_textfield" id="<%= @project.id %>" name="overview"><%= @project.overview...
my environment.rb contains:
ENV['GEM_PATH'] = File.expand_path('~/.gems') + ':/usr/lib/ruby/gems/1.8'
My gemfile contains:
source 'http://rubygems.org'
source :gemcutter
gem 'rails', '3.0.0.rc'
gem 'mysql'
gem 'haml'
gem 'RedCloth'
gem "friendly_id", "~> 3.0"
gem 'agnostic-will_paginate', "~> 3.0.0"
# Use unicorn as the web ser...
Since the latest Rails 3 release is not auto-loading modules and classes from lib anymore,
what would be the best way to load them?
From github:
A few changes were done in this commit:
Do not autoload code in *lib* for applications (now you need to explicitly
require them). This makes an application behave closer to an engine
(code...
I'm using rails3.rc and activerecord3 (with meta_where) and just started to switch to sequel, because it seems to be muuuuch faster and offers some really great features :-)
I'm already using the active_model plugin (and some others). But here are some questions I found and which I didn't find any documentation for:
As far as I know, ...
In routes.rb I was forced to add:
post 'admin/user_update'
to get my form_tag to work:
form_tag( { :action => :update_user, :id => @user.id }, :remote => :true )
Now I get:
Template is missing
Missing template admin/update_user with {:handlers=>[:erb, :rjs, :builder,
:rhtml, :rxml], :formats=>[:html], :locale=>[:en, :en]} in...
I have a form_for in a template new.html.erb where I do the normal save to the DB and then an e-mail on success. I want the mailer to send the same new.html.erb as the body and pass the model so that the form is fully populated. I'm getting the following error:
undefined method `protect_against_forgery?' for #<#<Class:0x000000049d7110>:...
So Rails doesn't have support for :through associations through a habtm relationship. There are plugins out there that will add this in for Rails 2.x, but I'm using Rails 3 / Edge, and only need the association for one particular model. So I thought I'd stump it out myself with the beauty that is Arel.
First, the models:
class CardSet ...
I think the code is more explicit
option A
class RedirectController < ApplicationController
def index
redirect_to :controller => 'posts', :action => 'show', :id => 1
# it works
end
end
option B
class RedirectController < ApplicationController
def index
render :controller => 'posts', :action => 'show', :id => 1
...
Hi,
I've got a plugin I'm using for websites using Rails 2.X or Rails 3.
In Rails 2.3, I used a lot the 'scoped' method for complex queries :
p = Person.scoped({})
p = p.active
p = p.with_premium_plan if xyz
p
etc.
But I saw that it changed in Rails 3 :
p = Person.scoped
etc.
So is it normal that I have to do something like that ...
I am trying to install the Facebooker plugin on Rails 3 RC with Ruby 1.9.2-RC2 but I am having some problems.
when I run
rails plugin install git://github.com/joren/facebooker.git
I get the following error
Plugin not found: ["git://github.com/joren/facebooker.git"]
and the facebooker.yml configuration file is not being generate...
Hi,
I've recently started learning Ruby on Rails, based on RoR3 beta/RC. I had earlier been developing applications using other frameworks (like Django), where the JavaScript had been written completely on my own.
When developing application using RoR, I get confused by the two possible ways of implementing JavaScript: the "pure" one (w...
I'm trying to install MongoDB in Rails 3 but when I'm trying to run 'bundle install', it freezes in "Fetching source index...". I tried with rubygems.org and gemcutter.org and both of them freeze.
Any ideas how to make it work?
...
I've implemented the following scope in a rails 3 application:
scope :popular, lambda { |l = 5| order('views desc').limit(l) }
However, it seems that when you attempt to count its records directly it doesn't apply the scope filters.
For example:
Post.popular.size #=> 20
Checking the log, it executes the following query:
SQL (0.4m...