Displaying 20 results from an estimated 78 matches for "model_nam".
Did you mean:
model_name
2012 Apr 25
2
Rails 3.1 - Scaffolding Files
Where can I find more information about the new syntax on these:
<%- model_class = @product.class -%>
<h1><%=t ''.title'', :default => t(''helpers.titles.new'', :model =>
model_class.model_name.human,
:default => "New
#{model_class.model_name.human}") %></h1>
<%= render :partial => ''form'' %>
I''ve been using rails for a little bit and the "model_class = ..." is all
new to me, plus I can...
2006 Jun 17
0
Dynamic forms containing collections
Hiall,
I have the following problem: I need to use forms containing
collections (i will call them FCC), and I want to construct them
dynamically, as I need to deal with quite large forms (more than 600
input fields).
The variables @model_name and @field_name contain the proper model and
field names as strings, which is enough for "normal" form input
fields. (i.e. the "if @history_size == 1" path of the code below works
fine!) However, when using FCCs there needs to be a loop over the
instance variable which "co...
2007 Apr 01
12
How to List Records in Descending Order?
I am brand-new to RoR and have only followed and replicated the few
tutorials that are out there.
I have searched and searched, but cannot find an answer to this simple
question:
How can you list records in descending order?
I have the cookbook example loaded, but can''t seem to list the recipes
in reverse order (by the primary key - id).
Thanks ahead of time for any and all help.
--
2006 Mar 23
6
easy scaffold question(s)
...ell 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 the simple structure set up? This naming
convention seems easy to me and should work. I''d like feedback on this
before I "make it real" for my process notes.
Second question. with this convention I''m ru...
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 : <%= f.text_field :key %>
33: Value : <%= f.text_field :value %&g...
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
2010 May 10
7
NilClass passed to partial view
...ompany/_form"(scaffold generated), I want to display the
address form. So I added (following Rails Guides) the following line to
my view :
<%= render :partial => "addresses/edit", :locals => { :shippingAddress
=> @address} %>
It keeps saying : "undefined method `model_name'' for NilClass:Class "
tried this :
<%= render :partial => "addresses/edit", :locals => {
@company.shippingAddress => @address} %>
with the same result
I''ve tried with :
<%= render :partial => "addresses/form", :object => @billingA...
2006 Apr 27
3
collection_select to display 2 fields
...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 argument, but not when trying to concatenate 2.
Any help is appreciated!
My code is below:
this works:
<%=collection_select(:model_name, :field_name, @queryname, :id,
:field_name_1)%>
this doesn''t work:
<%=collection_select(:model_name, :field_name, @queryname, :id,
:field_name_1 & :field_name_2 )%>
--
Posted via http://www.ruby-forum.com/.
2005 Dec 31
3
[Model] [Noob] Table Naming w/ underscores
Greetings:
I am writing a basic accounting module for an app. Rather unfortunately the
name "transactions" is a reserved term in Rails (being the only accounting
term trully representational of a financial transaction). I am left to come
up with other names. One such name was f_transaction.
This worked on the DB level, but I noticed that the Model name dropped the
underscore, thus
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'' %>
4: <% end %&...
2010 Apr 02
7
Liebert GXT2 NUT driver
Hi guys,
I found the troblue and fix it!
I attached the patch.
The trouble was in the command reply buffer use.
You compute the value that value = reply[6]*256+reply[5] <- it's wrong
The right solution: value = reply[5] * 256 + reply[6];
And other bug,
battery.runtime compute, you divide this value 60 <- it's wrong
right value: divide 1.0
I continue the work on this
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
2006 Jun 18
2
using javascript to get an attribute using an ID
Hi everyone,
I''m trying to use ajax to update the selected value of a select element.
Here''s what I have so far:
function RailsModel(model_name)
{
this.model_name = model_name;
}
RailsModel.prototype.getAttributeById = function(attribute, id)
{
Ajax.Request(''/models/get_attribute_by_id/'' + this.model_name + ''/'' +
attribute + ''/'' + id,
{
onSuccess:...
2011 Jan 26
13
undefined method `model_name' for NilClass:Class
...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 c:/Gpsappm/app/views/user_comments/_form.html.erb where line #1
raised:
undefined method `model_name'' for NilClass:Class
Extracted source (around line #1):
1: <%= form_for(@user_comment) do |user_comments| %>
2: <% if @user_comment.errors.any? %>
3: <div id="errorExplanation">
4: <h2><%= pluralize(@user_comment.errors.count, "error&q...
2006 Jul 06
3
Accessing form field contents
I have an HTML form on the screen, that is connected to a database
(standard Ruby way). I found that there are people that would rather not
fill in this information, but would rather search Amazon for the info.
Therefore, I added a link to the right of one of the fields that, when
pressed, will search Amazon for what ever you typed into that field.
So, how can I do that? At first I tried
2012 Apr 14
7
undefined method `model_name' for NilClass:Class
...lass="field">
<%= f.label :responsible %><br />
<%= f.text_field :responsible %>
</div>
I always get the following error message:
NoMethodError in Activities#new
Showing .../app/views/activities/_form.html.erb where line #1 raised:
undefined method `model_name'' for NilClass:Class
Extracted source (around line #1):
1: <%= form_for(@activity) do |f| %>
2: <% if @activity.errors.any? %>
3: <div id="error_explanation">
4: <h2><%= pluralize(@activity.errors.count, "error") %>
prohibited...
2013 Apr 02
4
gmaps4rails: undefined method `model_name' for NilClass:Class
...ollege_id %>
</div>
<div class="actions">
<%= f.submit %>
</div>
<% end %>
This is the error msg in full:
NoMethodError in Locations#new
Showing *C:/Postgrads0204/app/views/locations/_form.html.erb* where line *#1
* raised:
undefined method `model_name'' for NilClass:Class
Extracted source (around line *#1*):
1: <%= form_for(@location) do |f| %>
2: <% if @location.errors.any? %>
3: <div id="error_explanation">
4: <h2><%= pluralize(@location.errors.count, "error") %> prohi...
2008 May 30
9
find_by_sql without a model? how to do this?
...el
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>, however
within one method I need specific information (a group by) about data in A
that will not come back in the form of the model itself. Current I do use
<model_name>.find_by_sql(...) and get back an array which I use. This is
fine however syntactically to me the <model_name>...
2006 Aug 04
4
DRY DRY DRY
...class.find(params[:id]).destroy
flash[:notice] = sprintf(_(:deleted),
_(model_class.table_name.to_sym))
redirect_to :action => :list
end
private
def initialize_crud_controller
id = self.object_id
session[id] = { :page => 1 } unless session[id]
@sess = session[id]
@model_name = model_class.table_name.singularize
end
end
...
By the way, is this a good way to go?
Should something like this be generated when you generate scaffold?
I believe it should!
Then our custom controller looks like this:
controller/regions_controller.rb
...
class RegionsController < BasicCR...
2006 Feb 13
1
dynamically generating a controller and appropriate routing
...ng controller from within my_library.rb:
class ASampleController < ActionController::Base
def some_thing
render_text "hello world!"
end
end
and also from within my_library.rb I have the following code to add a route:
ActionController::Routing::Routes.connect ''/show/:model_name/:id'',
:controller => ''ASampleController'', :action => :model_name.to_s
However, the route doesn''t seem to be put in place, or even recognized. If I
examine ActionController::Routing::Routes from within the console, my route
does not show up. When I attempt...