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 Display Modes
  #1 (permalink)  
Old February 27th, 2009, 12:20 PM
Registered User
Join Date: Feb 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Chapter 5 - Tying controls to models

Had some issues to get this of the ground with the new version of ROR. And tried to find the solution in here - no luck.

But here is a solution that work as supposed.

---- look_controller.rb ----
class LookController < ApplicationController
  def at
    @data_hash = params[:cruncher]
    @cruncher = Cruncher.new(@data_hash[:crunch])

    @data = @cruncher.crunch

  def input
    @cruncher = Cruncher.new("")
---- cruncher.rb ----
class Cruncher 
  attr_reader :crunch
  attr_writer :crunch

  def initialize(data)
    @crunch = data

---- at.rhtml ----
    <title>Using HTML Control Shortcuts</title>

    <h1>Using HTML Control Shortcuts</h1>
    This application uses Rails HTML control shortcuts.
    Your name is <%= @data %>.
---- input.rhtml ----
    <title>Using Text Fields</title>
    <h1>Working With Text Fields</h1>
    This Ruby on Rails application lets you read data from text fields.
    <%= form_tag ({:action => "at", :method => "post"}) %>
      Please enter your name.
      <%= text_field ("cruncher", "crunch", {"size" => 30}) %>
      <input type="submit"/>
    <%= form_tag %>

Thread Tools
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
Chap. 5, Confusion: Tying Controls to Models mprogers BOOK: Beginning Ruby on Rails 3 December 12th, 2008 02:13 AM
Report Builder Models? SQLScott Reporting Services 2 October 26th, 2007 01:34 PM
Problem accessing Simulink models from C# karveajit C# 1 July 14th, 2006 12:55 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 02:10 AM.

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