Advertisement

08.19.2008 at 10:12AM PDT, ID: 23660399 | Points: 500
[x]
Attachment Details

Ruby will not generate bug reporting/error reports

Asked by lschwing in Ruby Scripting Language, Apple Software, WebApplications

Tags: , , ,

I am trying to get error messages to post when a post is done with improper data inputted. I am following the RailsSpace book ch 4 if this helps you out at all.

Code in application.html.erb:
                  <% if flash[:notice] -%>
                        <div id=:"notice"><%= flash[:notice] %></div>
                  <% end -%>
                  <% if ENV["RAILS_ENV"] == "development" %>
                        <% debug(params) %>
                  <% end %>

Code in register.html.erb:
                        <% error_messages_for "user" %>
                fixed:<%= error_messages_for "user" %>



Running Rails 2.1, actionpack 2.1, WEBrick, pretty much default stuff. I am very new to RoR and trying to learn.Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
application.html.erb in myrubyapp/app/views/layouts
 
<!DOCTYPE HTML PUBLIC "-//W3C/DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xthml1-strict.dtd">
 
<html>
	<head>
		<title><%= @title %></title>
		<%= stylesheet_link_tag "site" %>
	</head>
	
	<body>
		<div id="whole_page">
			<div id="header">ThingsTaDo.com</div>
			<div id="nav">
				<%= link_to_unless_current "Home",		:action => "index"%> |
				<%= link_to_unless_current "About Us",	:action => "about"%> |
				<%= link_to_unless_current "Help",		:action => "help" %> |
				<%= link_to_unless_current "Register",	:action => "register",
														:controller => "user" %>
			</div>
			<div id="content">
				<%= @content_for_layout %>
			</div>
			<% if flash[:notice] -%>
				<div id=:"notice"><%= flash[:notice] %></div>
			<% end -%>
			<% if ENV["RAILS_ENV"] == "development" %>
				<% debug(params) %>
			<% end %>
		</div>
	</body>
</html>
 
_________________________________________________________________________________________________________
 
Register.html.erb in myrubyapp/app/views/sites
 
<h2>Register</h2>
<% form_for :user do |form| %>
	<fieldset>
		<legend>Enter Your Details</legend>
		
		<% error_messages_for "user" %>
		
		<div class="form_row">
			<label for "screen_name">Screen Name:</label>
			<%= form.text_field :screen_name,
								:size => User::SCREEN_NAME_SIZE,
								:maxlength => User::SCREEN_NAME_MAX_LENGTH %>
		</div>
		<div class="form_row">
			<label for "email">Email:</label>
			<%= form.text_field :email,
								:size => User::EMAIL_SIZE,
			 					:maxlength => User::EMAIL_MAX_LENGTH %>
		</div>
		
		<div class="form_row">
			<label for "password">Password:</label>
			<%= form.password_field :password,
								:size => User::PASSWORD_SIZE,
								:maxlength => User::PASSWORD_MAX_LENGTH %>
		</div>
		<div class="form_row">
		<%= submit_tag "Register!", :class => "submit" %>
		</div>
	</fieldset>
<% end %>
 
___________________________________________________________________
user controller located in myrubyapp/app/controller/user_controller.rb
 
class UserController < ApplicationController
 
  def index
  end
 
  def register
    @title = "Register"
    if request.post? and params[:user]
      @user = User.new(params[:user])
      if @user.save
        flash[:notice] = "User #{user.screen_name} created!"
        redirect_to :action => "index"
      end
    end
  end
end
[+][-]08.19.2008 at 01:15PM PDT, ID: 22263466

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08.19.2008 at 04:18PM PDT, ID: 22264838

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08.20.2008 at 01:57PM PDT, ID: 22273841

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628