Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Open Source > BOOK: Beginning Ruby on Rails
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old June 7th, 2008, 08:40 PM
Registered User
Points: 45, Level: 1
Points: 45, Level: 1 Points: 45, Level: 1 Points: 45, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2008
Location: , , .
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
  #2 (permalink)  
Old June 10th, 2008, 02:12 PM
Registered User
 
Join Date: Jun 2008
Location: , , .
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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!

  #3 (permalink)  
Old June 10th, 2008, 04:36 PM
Registered User
Points: 45, Level: 1
Points: 45, Level: 1 Points: 45, Level: 1 Points: 45, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2008
Location: , , .
Posts: 9
Thanks: 1
Thanked 0 Times in 0 Posts
Default

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

  #4 (permalink)  
Old December 12th, 2008, 03:13 AM
Registered User
 
Join Date: Dec 2008
Location: Shizuoka, Japan
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

Quote:
<html>
<head>
<title>Using Text Fields 2</title>
</head>

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

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

</body>
</html>
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 08:33 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.