Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Open Source > BOOK: Beginning Ruby on Rails
BOOK: Beginning Ruby on Rails
This is the forum to discuss the Wrox book Beginning Ruby on Rails by Steve Holzner Ph.D.; ISBN: 9780470069158
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning Ruby on Rails section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old June 7th, 2008, 08:40 PM
Registered User
Join Date: Jun 2008
Posts: 9
Thanks: 1
Thanked 0 Times in 0 Posts
Default Chap. 5, Confusion: Tying Controls to Models

Hi, All:

I've been reading through this book, and it's been *super* up until the section in chapter 5 on tying controls to models. The author says that "cruncher" is the name of a model object, yet in input.rhtml (p. 147), that html is called *before* any cruncher object is created (in the at method).

Furthermore, I tried changing

text_field("cruncher","crunch") ===> text_field("tcruncher","xcrunch"), and, after adjusting params[:cruncher] to params[:tcruncher], and @data_hash[:crunch] to @data_hash[:xcrunch], things still worked.

I guess I don't understand what the parameters "cruncher" and "crunch" really signify. The book states that they are supposed to be named after the model and attribute, respectively, but they don't have to be, as my experimenting demonstrated.

Is it just convention that the arguments to text_field be the lowercase name of the model and its attribute, or will this turn out to be useful later on?

Any enlightenment would be most appreciated!

Michael Rogers
Old June 10th, 2008, 02:12 PM
Registered User
Join Date: Jun 2008
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts

I agree that the book was super, but I have laid it aside for now.

Besides trying to get Models and the crunch/cruncher thing working, I lost it earlier with Rails Shortcuts p. 137. I am using Rails 2.0.2 and there are a number of deprecated tags and "post" doesn't work.

I have tried everything I could think of for both tags and models.

Without these 2 things working, the rest of the book doesn't look very useful.

It would be great if the author would address these issues.

Does anyone know of a book that would be useful in trying to learn Rails (2.0.2)? Of course, it would be equally great is someone could figure out how to make the stuff in "Beginning Ruby on Rail" to work.

Good Luck!

Old June 10th, 2008, 04:36 PM
Registered User
Join Date: Jun 2008
Posts: 9
Thanks: 1
Thanked 0 Times in 0 Posts

Hi, rgonnering.

Thanks for getting back to me. I'm not sure what problems you were having with the shortcuts, but I did post a solution to your post problem in another thread in this forum.

As far as my original problem is concerned, it *appears* -- and if somebody else knows differently, please advise me -- that the connection between the view and the model has to be made by the programmer. You name *all* your html controls the same, so params[:thatname] returns a hash, and then the second parameter in the control becomes the key into that hash.

I thought that progamagically the view would know the model, and update its attributes, but that doesn't seem to be the case.

Michael Rogers

Old December 12th, 2008, 03:13 AM
Registered User
Join Date: Dec 2008
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Thumbs up P137 textfields2

P137 textfields2

input.rhtml -> input.html.erb
works on RoR 2.2.2

<title>Using Text Fields 2</title>

<h1>Working With Text Fields</h1>
This Ruby on Rails application lets you read data from text fields.

<% form_tag('/look/at') do %>
Please enter your name.
<%= text_field_tag ("text1", "", {"size" => 30}) %>
<%=submit_tag (value="SUBMIT") %>
<% end %>


Similar Threads
Thread Thread Starter Forum Replies Last Post
Report Builder Models? SQLScott Reporting Services 2 October 26th, 2007 01:34 PM
Chap 17 error: only content controls... Torq BOOK: Beginning Visual Basic 2005 ISBN: 978-0-7645-7401-6 0 September 8th, 2007 10:03 AM
tying in animation to music nancy Flash (all versions) 0 May 31st, 2005 01:35 PM
Big models question darrinps BOOK: Expert One-on-One J2EE Design and Development 0 June 4th, 2003 02:10 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.