similar to: MVC and modules. Views telling models to behave

Displaying 20 results from an estimated 1000 matches similar to: "MVC and modules. Views telling models to behave"

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 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: <%
2007 Nov 29
3
Stylistic preferences
What are people''s opinions on which of these two styles is better to use? 1) before --------------------------- module UserSpecHelper include GenericSpecHelper def valid_sms_attributes(phone_number="12345") { :phone_number => phone_number } end end describe User, "with phone number" do include UserSpecHelper before(:each) do @user =
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/.
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
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
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
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/.
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
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 Jun 08
3
MVC and Pagination
Just wondering how to best integrate with pagination and still stick to MVC... Say I have a Post model that has a published attribute. I want to show all the recent published posts on a page. My first instinct is to create a method in the Post model called recent that does the find with proper conditions and order, but the problem I have is how do I use that with pagination (which definitely
2006 Jun 21
0
rails MVC
Bonjour a tous, voila j''ai quelque soucie a comprendre comment s''enchaine les appels de la vue/controleur/model dans Rails :( j''ai une classe qui me permet de faire la liaison entre ruby et c++ (ca marche parfaitement) que j''ai mis ds le repertoire model (je ne l''ai pas cree avec generate parce que je ne veux pas de BD! et j''avais
2007 Nov 05
0
Scruffy > MVC architecture?
Hi, I am a newby in rails...and i have read that scruffy is a great tool to create/display images. Now i find the code below for example... graph = Scruffy::Graph.new graph.title = "Comparative Agent Performance" graph.value_formatter = Scruffy::Formatters::Percentage.new(:precision => 0) graph.add :stacked do |stacked| stacked.add :bar, ''Jack'', [30, 60, 49, 29,
2006 Aug 11
3
General architechture / MVC question
Hi all, A newbie with Ruby on Rails - and programming in general - I''m working on a few Flash and PHP projects as well. Partly to make my work more efficient, partly to gain a better understanding of system architecture / design patterns, I''ve been trying to use the MVC pattern in database-backed Flash / Actionscript development as well. I think / hope that I''m
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
2006 Aug 01
5
MVC question
Should I create a separate controller for each model or should I use 1 controller for all models? Having 1 "admin" controller for all backend stuff seems logic to me, but when I scaffold it rather makes 1 controller per model. I''m fairly new to the MVC pattern, so what''s the prefered way of doing it? I''m also wondering if the API is up to date? When
2007 Oct 09
0
[Slightly OT] MS MVC taking slight hints from Merb
http://www.hanselman.com/blog/ScottGuMVCPresentationAndScottHaScreencastFromALTNETConference.aspx In Scott Guthrie''s talk (about 43:30) he mentions requiring the render call as a convention. Interesting to see Merb influence Microsoft. :) -- Cheers, Kevin Williams http://kevwil.com/ http://www.almostserio.us/ http://kevwil.jaiku.com/
2006 May 08
3
MVC newbie question
All, Is it possible for a view to call back to a controller method? If so, what is the syntax? === details I have a list view that I want to filter out inactive rows based on several table fields being zero, old, etc. It would seem I should create a "filtered" method in the controller (which I have done). Then invoke if from the view like: for row in @rows continue if row.filtered
2006 May 22
1
MVC and cron jobs
I have a cronjob that runs "ruby script/runner ''Channel.preload''". Channel is a parent model, Item is the child model (i.e., Channel has_many :items and Item belongs_to :channel). The coupling is minimized, the coherence looks good, but I''m not sure the model is the right place to put this code. Is there a better place to put this code, e.g., a component (I