Displaying 20 results from an estimated 130 matches similar to: "Stylistic preferences"
2007 Sep 04
3
Model Specs: Fixtures vs Mocks + Stubs?
What is the general opinion about fixtures versus mocking and stubbing
in model specs? I heard from agile on IRC that they save the database
testing for integration testing, but I also see that the caboose
sample applicaiton uses fixtures. I also noticed that on the rspec
site, it says "Ironically (for the traditional TDD''er) these are the
only specs that we feel should actually
2007 Nov 14
4
Stubbing out required associated models
Hello,
As I''m becoming more and more familiar with mocking/stubbing, I''m going back
to some of my model specs and revaluating how I wrote them.
I have certain models in which validation requires the presence of an
associated model, which itself needs to be valid(validates_presence_of and
validates_associated).
When I wrote the specs, I wrote helpers for the attributes instead
2006 Aug 14
2
ActionPack: number_to_phone error
Question about the number_to_phone function as provided by rails in actionpack:
http://api.rubyonrails.org/classes/ActionView/Helpers/NumberHelper.html
If I do this in my controller:
num = number_to_phone(params[:phone_number])
I get this error:
undefined method `number_to_phone'' for #<TicketsController:0xb7a2bfcc>
Whereas if I do this in my view:
<%
2006 May 09
11
model filter?
Hi All,
Is there a way to filter / modify the output of a model class before
it''s returned to controller/view that''s calling it?
Example: I have a field phone_number which I always want to preformat
using the number_to_phone() helper....
Any help is appriciated.
Thanks!
--
Posted via http://www.ruby-forum.com/.
2006 Jul 05
0
Javascript repeating fields.
The one area I keep hitting my head against in Rails is repeating fields via
javascript. I frequently have forms where one or more fields are actually
broken out into sub tables because there can be multiple simultaneous values.
Rails seems to want to you to use the [] construct in the form helpers (e.g.
text_field(''employee[]'', ''name'')), but I can''t
2007 Oct 11
2
Login testing ideas
I''ve been going through Pat''s example story and noticed that there was
no checking for a bad login. I assume this is because that would have
made the article bigger and more complicated than it needed to be.
So the question that comes of of this is:
How do folks normally handle the negative case? My plan was to just
use another scenario, but as a new person to BDD/TDD,
2007 Feb 23
2
how to remove spaces from phone number
Hi,
I need to allow login based on the phone number. During the signup they
can give the number in any format with spaces, slash or (). But for
storing in database and then during login to compare I just want the 10
digit number. How can I remove the special char from phone number before
storing to db ?
Thanks.
--
Posted via http://www.ruby-forum.com/.
2006 Jul 31
3
getting the last four digits of a string or number
I want to trim down a phone number to the last four digits before saving
it to the db. How would I do this? For example, 800-555-1212 which
could also be 8005551212, i want to save just 1212 (last four digits)
only.
--
Posted via http://www.ruby-forum.com/.
2008 Nov 04
3
Nester Resources, Routes and Class Inheritance
Ok here''s a quicky... but a goody :)
We have models Company, Reference and Applicant... and References and
Applicants just inherit from Company, and are basically companies with
the type field set to reference...
All companies can have a phone number associated with them, and phone
number is a different model...
I''m having trouble using the form_for method with a company that
2006 May 24
1
does select support arrays in a form with multiple models?
i have a one-to-many model (an addressbook of contacts with many phone
numbers). i want to represent a select element so that its name is an
array containing the phone_number id...
<select id="phone_number_1_location_or_kind"
name="phone_number[1][location_or_kind]">
<option value="Work">Work</option>
<option
2006 Feb 15
6
error_messages_for trouble
I am trying so learn how to do custom validations.
The validation works as expected, but I can''t get "error_messages_for"
to display.
How is the name of the object supposed to be formated?
Where is this object created, the model or controller?
What am I doing wrong here?
#### Model ########################
class MyFolder < ActiveRecord::Base
def validate
# validation
2005 Mar 10
1
Asterisk@Home, AMP, and Broadvoice
Egad, not again with Broadvoice! Anyhow, I recently installed AAH and
configured my TDM11B and got that and some SIP phones working. I still
have some issues to work out, etc, but my current problem is Broadvoice.
I have checked out all of the online resources, including the recent
list exchange about the recent changes made by Broadvoice. However, the
one thing I have found to be consitent in
2007 Jun 24
6
I only want one type of model returned from a multi_search
I am trying to use acts_as_ferret''s multi_search to search across
multiple models, but i only want it to return one type of model.
for example i have a page that lists out people. on this page it shows
email addresses and phone numbers. I want to be able to search by any
fields directly from the person model and search the fields from the
email_address and phone_number models, but I only
2006 Oct 20
7
MVC and modules. Views telling models to behave
I was thinking today, it would be nice if a view could tell a model how to
format it''s data for that particular view.
Kind of like, the view is bestowing instant, and temporary knowledge on the
model for the duration of the views run.
It seemed to me that this would be more objecty than say a helper that
formats a string
format_my_string( my_string )
Instead, in my view. Lets assume I
2006 Apr 14
7
How to call a java function in rubyonrails method
Hi everyone,
I''m Italian and sorry for my english mistakes...
I''m developing a web-site using rubyonrails.
It''s REALLY COOL!
But I''m obliged to re-use some javascript functions.
Do you know where I can get the right documentation (and examples) in
order to integrate these two different environments?
Thanks,
Matteo.
--
Posted via http://www.ruby-forum.com/.
2008 Mar 19
2
Stub / Mock - A little guidance?
Hi there,
I''m still trying to wrap my head around when to use a stub and a mock.
If I understand this right, I should be using a ''mock'' when imitating
an object, but not its behavior. I should be using a stub when I want
to imitate the behavior of an object. Does that sound about right?
With that said, I''m struggling a little trying to spec out this
instance
2009 Sep 21
0
Polymorphic form
I have two partials to deal with contact information. The Contact
information uses single-table polymorphism. I want to be able to use
save on Contact and set ''type'' manually, based on the type of form the
user is filling in. This is saved as the value on a hidden field.
class Contact
belongs_to :person
acts_as_list :scope => :person
validates_presence_of :type
2007 Jul 12
0
is it possible to get id of the matched field?
i want to create link on the matched field:
f.e. i have person and phone models.
class Person < ActiveRecord::Base
has_many :phones
acts_as_ferret :fields => [:phone_numbers]
def phone_numbers
phones.collect{|phone| phone.number}
end
end
search result''s page lists out people with matched phone_numbers
highlighted.
i want to create link on matched phone_number to get
2006 May 09
7
polymorphic relation question
I am trying to get polymorphic relations to work for my app. What I am
trying to do is explained by this picture
http://iroll.org/code/
I can''t figure out the code for in the controller to create a new
phone_number and assign it to a person. I have tried everything I can
think of.
A) do my models look correct?
B) what would the commands look like in the console or a controller
action
2012 Sep 15
2
[RSpec Testing] Methods take two arguments
Hello,
Here is my *pdf_helper.rb* => http://pastebin.com/QU1kTKXk. I want to test,
if self.create method can take more than two arguments. But, when I try to
run my test. It showed
*PdfHelper Should have two arguments
Failure/Error:
create_pdf.should_receive(object,template).with(user,file)
NameError:
undefined local variable or method `create_pdf'' for