Displaying 20 results from an estimated 2000 matches similar to: "Rails 3.1 - Scaffolding Files"
2006 Aug 04
4
DRY DRY DRY
Hello everyone!
Ive been on rails for the last month or so and really enjoyed this
framework.
However its very hard to find documentation on how to do things right!
For example every beginner after a while realizes that having similar
CRUD actions in every controller and views for them is not DRY at all!
Few days ago I found http://dereksivers.com/rails-shared-controller.html
I quite like his
2006 Apr 18
4
how would you take the duplication out of this?
i have these two really similar methods in my addressbook controller.
def edit_company
@company = Company.find(params[:id])
if request.post? and @company.update_attributes(params[:company])
flash[:notice] = ''Company was successfully edited.''
redirect_to :action => ''show'', :id => @company
end
end
def edit_person
2011 Jun 29
6
RSpec with Rails 3.1rc4: spec test won't recognize <%= %> (should be simple)
In my user_sessions_controller:
class UserSessionsController < ApplicationController
before_filter :require_no_user, :only => [:create, :new]
before_filter :require_user, :only => :destroy
def new
@user_session = UserSession.new
@message = "Hello."
end
def create
@user_session = UserSession.new(params[:user_session])
if @user_session.save
2006 Mar 23
6
easy scaffold question(s)
I''m doing very well with the Hibbs Rolling on Rails tutorial. I have an
easy question for my personal notes. I''m coming up with a simple framework
of steps for creating a basic database. It includes the following maxims to
make original app creation easy:
app_name = MySQL database name
SQL_tablename = model_name
model_name = controller-name
Is this going to work for getting
2006 Jun 08
3
Macros and stuff
I was looking at my controller code and the edit/create/update/new for
each are practically identical. So first I DRY''d the four methods in
each controller to just one and then I decided to write a single macro
for all my controllers.
This is the macro:
def self.edit_action_for(model, options = {})
model_class = Object.const_get(model)
define_method(:edit) do
2011 Mar 29
18
Rails 3.0.6.rc1
ZOMG HAPPY TUESDAY (UTC-7)!!! <3<3<3<3<3
I am happy to announce that the first release candidate for Rails 3.0.6 has
been pushed to rubygems.org.
## Release Candidate: What does it mean?
The release candidate is very similar to what we will actually release for
version 3.0.6. The reason that we release an RC is so that the community can
have a chance to postpone or veto commits
2006 Apr 27
3
collection_select to display 2 fields
I''m trying to get a collection_select generated Drop-down box to display
two fields from a table (first name & last name); however, I am having
trouble concatenating the symbols. It appears as though any code I put
in the 5th argument for collection_select is processed prior to
executing the collection_select method. The code executes successfully
with 1 symbol in the 5th
2006 Jun 01
4
can''t convert Fixnum into String ??
I have been getting this error message on various pages, just wondering
if anyone could explain whats going wrong, and the best way to correct
it
code that is cuasing the problem is below
@project = Project.find(:first, :conditions => "id = " +
@purchaseorder.project_id)
--
Posted via http://www.ruby-forum.com/.
2006 May 12
4
default value in text field
hi,
This should be really simple, but i cant seem to find the answer
anywhere!!
In my _form.rhtml I have the following text field, how can I define a
default value?
<%= text_field ''purchaseorder'', ''number'' %>
--
Posted via http://www.ruby-forum.com/.
2012 Sep 03
0
undefined method `singular_route_key' for "User":ActiveModel::Name
In ActionDispatch::PolymorphicRoutes, there is a call to
build_named_route_call an on line 172 (of latest rails code from
github), there is a call to singular_route_key:
model_name_from_record_or_class(parent).singular_route_key
Now model_name_from_record_or_class returns an ActiveModel::Name
object, which is a wrapper to the string class, that returns a string
name of the class of an
2007 Mar 29
21
a better "should have valid associations"
This is pretty much the same as last time around, if you recall.
Thanks to Wilson for converting to the new form. I''ve added a few
lines. Basically, it iterates over your model associations and does
two things.
- First, just try to call the association. Usually fixes speeling
erors or other such silliness.
- Second, try to find a record with an :include on the association.
This
2006 Jan 04
4
file_column
I use file_column and it works fine.
I tried to change the store_dir to a the path I want my files to be
stored and not the default.
I stored some images fine. But when I try to reach my images it seems
like file_column uses the model_name/attribute_name on the image and not
the store_dir I used. How can I change this ?
Thanks in advance
--
Alexander Antonakakis
2008 May 30
9
find_by_sql without a model? how to do this?
Hi,
I''d like to do a "find_by_sql" without a model (e.g. <model
name>.find_by_sql("...")) as the results I get back are a once off special,
and I''m happy to handle them as an array. How do I do this?
"ActiveRecord::Base.find_by_sql(...)" does not seem to work?
Background - At the moment I''m doing within a model <model_name>,
2006 Feb 13
1
dynamically generating a controller and appropriate routing
I''m working on a library similar to acts_as_taggable. I''d like it to be a
simple, one file drop-in: i.e., put my_library.rb into RAILSROOT/lib/ and
have everything work. However, the library requires a controller to render
some stuff, so I need to be able to create the controller class, set the
routing, and extend the controller at run-time from within my_library.rb.
I have code
2010 May 10
7
NilClass passed to partial view
Hi,
I have a simple program that tries to do something really basic.
First, I have a company Model :
-------------------------------------
class Company < ActiveRecord::Base
has_one :billingAddress, :foreign_key=>"id", :class_name=>"Address"
end
Then I have the address Model :
--------------------------------------
class Address< ActiveRecord::Base
belongs_to
2011 Jan 26
13
undefined method `model_name' for NilClass:Class
I am new to Ruby on Rails and have a very simple foreign key example
that is driving me nuts. I am using Rails 3 under Windows Vista and have
two tables: users and user_comments. user_comments.user_id should
point to the user a comment is about.
In my show view for user I have a link to the new method of
user_comments to allow a comment to be created. This throws:
Showing
2009 Apr 19
19
Controller spec: testing that scope is set
In a Rails controller I set the scope on a model class in an around
filter. I have defined expectations on the model classes, and ideally, I
would add a further expectation for the scope. Is this already possible
in some way? How would I go about adding support a scope expectation?
Michael
--
Michael Schuerig
mailto:michael at schuerig.de
http://www.schuerig.de/michael/
2011 May 27
4
undefined method `model_name' for NilClass:Class in a form_for
Hi! I know that there are other topics about this issue, I read them and
I''m always blocked. Here is the error message:
undefined method `model_name'' for NilClass:Class
Extracted source (around line #30):
27:
28: <h2>Add Translation</h2>
29:
30: <%= form_for @new_trad do |f| %>
31: Locale: <%= f.text_field :locale %>
32: Key : <%=
2011 Aug 31
9
undefined method `model_name' for NilClass:Class in rails 3.0.0
Hi,
i got search which shows following error
ActionView::Template::Error (undefined method `model_name'' for
NilClass:Class):
1: <%= form_for(@employee) do |e| %>
2: EMP ID<%= e.text_field :id %><br>
3: <%= e.submit ''search'', :controller => ''employees'', :action =>
''search1'' %>
2012 Sep 19
7
Renaming Journey and avoiding libraries with common noun names
Hi all,
I know this is a long shot, but could renaming the "Journey" module please
be considered by those in a position to support it?
I''ve written an issue on this in the journey repo also:
https://github.com/rails/journey/issues/49
Essentially our project has a model named Journey, the same as Rails 3.2''s
new routing driver. As a consequence we can no longer