Displaying 11 results from an estimated 11 matches for "some_model".
2006 Nov 30
3
model stubs with view/controller specs: error_messages_for??
How would I set up a model stub so that <%= error_messages_for
''some_model'' %> doesn''t complain?
I started going down this road: @some_model.stub!
(:errors).and_return(ActiveRecord::Errors.new)
but it seems like a long, hopefully uneccessary road.
Cheers,
Michael
2006 Apr 26
6
Immediate help needed
I have posted this previously also but haven''t received any help.
So, if somebody could look into it and guide..
I want to validate the extension of files that I am uploading.
Like I want only the doc/pdf files to be uploaded..
Thanks in advance.
--
Posted via http://www.ruby-forum.com/.
2006 Apr 14
5
One Controller, Many models
Hello all,
I am working on a app right now that is going to replace a paper form
process out client has. This process has quite a few forms (about 30)
and different groups of forms (section) need to be filled out based on
what information is required from the user. For example, here is a
possible process of 2 users:
user 1 user 2
Section 1 Section 1
Section 2 Section 2
2008 Jul 02
2
How to write the method before_destroy and the test
How to write the method before_destroy?
Here is my code:
def before_destroy
errors.add(:isdefault,"Can''t destroy default record") if
self.isdefault
return false
end
or I should write it like below?
def before_destroy
raise(Can''t destroy default record") if self.isdefault
end
and how to write the test for it
--
Posted via
2006 Feb 15
2
extending rails via /lib - problems
...on.rb and views have helpers but I
couldn''t find anything about models. Using the /lib directory seemed to
be the only way.
Alright... so I have something like this:
/lib/code.rb
class ActiveRecord::Base
def method_a(n)
.......
end
def method_b(n)
........
end
end
/models/some_model.rb
class SomeModel < ActiveRecord::Base
def self.some_method(a, b)
........
end
def other_method
........
end
end
I also added `require ''code''` to enviroment.rb
My problem is that, for some reason, I can''t use any method declared in
code.rb inside `self...
2006 Jul 21
1
validates_acceptance_of weirdness
On my registration form I have a checkbox for a waiver. In the model I
have the statement:
validates_acceptance_of :waiver, :on => :create, :message => "must be
accepted"
In the view:
<%= check_box_tag("waiver") %>
<%= error_message_on "user", "waiver", "Waiver "%>
For some reason validate is accepting everything when the
2008 Apr 20
1
Why is respond_to always rending the RXML view?
I''m having a problem in Rails 2 where respond_to is always rendering the
RXML view even in the HTML rendering response. Can anyone tell me why
this might be happening? Here''s a code snippet:
respond_to do |accepts|
accepts.html
accepts.xml { render :action => ''show.rxml'', :layout => false}
end
If I change this to the following it works fine:
2010 Sep 16
3
Resyful authenticatio current_user in model
Hi,
I am using Restful authentication for user authentication.
I want the current logged in user object in my model property.rb
Problem is current_user is not working on model.
How can I fix this I need that?
Please help me out.
Thanks,
Mike
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk"
2009 May 07
13
what database field type should i use ??
in a database table if there is a field which has a certain set of
fixed values. for example
staus => {Single, Married, Divorced }
OR
state => {California, Albama, Olaska ...}
so what should be preferred way out of the following for storing the
values
1. Keep the field as "string(Rails)" VARCHAR(MySQL) itself ....and
while showing the field just show the field value.
2. Keep
2006 Mar 14
21
Changing default date format in Rails
I''ve spent all day digging through the rails api and postgres-pr on
this, I think it''s time to ask the list.
Postgres stores a Date in YYYY-MM-DD format. My users want the dates
in MM/DD/YYYY format.
Sure, I could explicitly convert it on the app level every place where
a date is displayed, but that seemed like a DRY violation.
I thought I''d be clever and simply
2013 Jun 22
4
ActiveRecord::Base.transaction - SystemStackError - stack level too deep:
Im having an issue that seems to only happen when trying to use a
transaction. Ive used transactions many times in the past and Im at a loss
as to why im getting the stack level too deep problem.
SystemStackError - stack level too deep:
actionpack (3.2.13) lib/action_dispatch/middleware/reloader.rb:70:in `''
I have a StackOveflow with more detail -