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 November 29th, 2006, 01:41 PM
Registered User
 
Join Date: Nov 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Initialize data in an HTML Control

I'm having an issue with Initialize data in an HTML Control on page 151 - the HTML Control is not being Initialize with the data. Any suggestion?

Thanks
bnewton1
-------------------------

look_controller.rb

class LookController < ApplicationController

  def at
    @data_hash = params[:cruncher]
    @cruncher = Cruncher.new(@data_hash[:crunch])

    @data = @cruncher.crunch

  end

  def input
   @cruncher = Cruncher.new("Steve")
  end
end


cruncher.rb

class Cruncher
  attr_reader :crunch
  attr_writer :crunch

  def initialize(data)
    @crunch = data
  end

end



input.rhtml

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Using Text Fields</title>
</head>
<body>
<h1>Working With Text Fields</h1>
<p>This Ruby on Rails application lets you read data from text fields</p>
<%= start_form_tag ({:action => "at"}, {:method => "post"}) %>
<%= text_field ("cruncher","crunch", {"size" => 30}) %>
<br/>
<input type="submit" />
<%= end_form_tag %>
</body>
</html>

[b ] at.rhtml [/b]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Using HTML Control Shortcuts</title>
</head>
<body>
<h1>Using HTML Controls Shortcuts</h1>
<p>This application using Rails HTml Control shortcuts</p>
<p>Your Name is <%= @data %></p>
</body>
</html>

-----------------

 
Old December 13th, 2006, 01:29 AM
Registered User
 
Join Date: Dec 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Also having a problem. Will not recognize "input".

Have you solved this?

 
Old December 14th, 2006, 07:31 PM
Registered User
 
Join Date: Dec 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I had the same problem. I restarted WEBrick and all was well. WEBrick is caching the model classes.

Cheers,
Jeff

 
Old December 16th, 2006, 10:26 PM
Registered User
 
Join Date: Dec 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hello:

Tried restarting Webrick; but did not cure the problem.

Are you using RadRails?

Jeff L.

 
Old January 17th, 2007, 09:23 PM
Registered User
 
Join Date: Jan 2007
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

bnewton1: Your code looks good, but there is an error in the book. After you start the WEBrick server you need to navigate to http://localhost:3000/look/input instead of http://localhost:3000/input.html like the book says. This should fix your problem.
 
Old July 27th, 2007, 05:24 PM
Registered User
 
Join Date: Jul 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I got the same problem. Restarting the script\server did not fix the problem.






Similar Threads
Thread Thread Starter Forum Replies Last Post
how to initialize arrays in c# apoorvchandra C# 2005 1 July 12th, 2008 08:35 PM
Need to be able to re-initialize a form kscase Visual Basic 2005 Basics 14 May 10th, 2007 09:54 AM
Converting an HTML Server Control to HTML Control gratisaccount ASP.NET 1.0 and 1.1 Basics 2 August 7th, 2006 12:29 AM
"Cannot initialize data binding" error gbianchi Pro VB 6 7 May 11th, 2006 08:08 AM
initialize variables junemo Pro PHP 2 July 15th, 2004 03:04 PM





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