Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9122059
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T06:00:20+00:00 2026-06-17T06:00:20+00:00

So I have been working on a multi-step form in ruby on rails (1.9.3)

  • 0

So I have been working on a multi-step form in ruby on rails (1.9.3) using Active model, following both the railscast #217 and #219 and am having problems with the validation the problem is that even if the attribute field is not blank it will still throw an error

1 error prohibited this wizard from being saved:
Validationattr can't be blank

I don’t beleive it should be saving but this may just be something to do with the error
. (I cannot use a form gem and must write this myself) let me know if you need any more information and i will be happy to provide.

My controller code – (contollers/awizard_controller.rb)

class AwizardController < ApplicationController

  def new
    # New Asset Wizard
    @wizard = Awizard.new(id: 1)
    # Set session variable as initial step
    session[:wizard_step] = @wizard.current_step
  end

  def update
    @wizard = Awizard.new(id: 1) unless !@wizard.nil?
    @wizard.current_step = session[:wizard_step] unless nil

    if @wizard.valid?
      if params[:back_button]
        @wizard.previous_step
      elsif @wizard.last_step?
        @wizard.save if @wizard.all_valid?
      else
        @wizard.next_step
      end
      session[:wizard_step] = @wizard.current_step
    end

    if @wizard.changed?
      render 'form'
    else
      @wizard.save
    end
  end

end

My awizard Model – (models/awizard.rb)

 class Awizard < Wizard
 validates :validationattr, :presence => true
 attr_accessor :validationattr

  def steps
    %w[validate_schedule validate_assets save_assets]
  end

 end

My wizard Model – (models/wizard.rb)

class Wizard
include ActiveModel::Validations
include ActiveModel::Conversion
include ActiveModel::Dirty
include ActiveModel::Naming

#This class is used to manage the wizard steps using ActiveModel (not ActiveRecord)

attr_accessor :id
attr_writer :current_step  #used to write to current step
define_attribute_methods [:current_step] #used for marking change

def initialize(attributes = {})
   attributes.each do |name, value|
     send("#{name}=", value)
   end
end

def current_step
  @current_step || steps.first
end

def steps
  %w[] 
end

def next_step
  current_step_will_change! #mark changed when moving stepped
  self.current_step = steps[steps.index(current_step)+1] unless last_step?
end

def previous_step
  current_step_will_change! #mark changed when moving stepped
  self.current_step = steps[steps.index(current_step)-1] unless first_step?
end

def first_step?
  current_step == steps.first
end

def last_step?
  current_step == steps.last
end

def all_valid?
  steps.all? do |step|
    self.current_step = step
    valid?
  end
end

def step(val)
  current_step_will_change!
  self.current_step = steps[val]
end

def persisted?
  self.id == 1
end

end

My views –
(/views/awizard/_form.html.erb)

<%=  content_for :awizard_form do%>
  <%= form_for(@wizard) do |f| %>
    <%= render "#{@wizard.current_step}_step", :f => f %>
    <%= f.submit "Previous", :name => "back_button" unless @wizard.first_step? %>
    <%= f.submit "Continue", :name => "step" unless @wizard.last_step? %>
  <% end %>
<% end %>

(/views/awizard/_step1.html.erb)

<div class="field">
  <%= f.label :validationattr %><br />
  <%= f.text_field :validationattr %>
</div>

(/views/awizard/_step2.html.erb)

<div class="field">
  <%= f.label 'Step2' %><br />
</div>

(/views/awizard/_step3.html.erb)

<div class="field">
  <%= f.label 'Step3' %><br />
</div>

Routes code

resources :awizard
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T06:00:21+00:00Added an answer on June 17, 2026 at 6:00 am

    The problem was as MrYoshiji stated without the parameters being passed through to step 2 the validationattr could not be validated in the wizard, adding in the controller a merge of the wizard params fixed this.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I have been working on a multi-step form in ruby on rails (1.9.3)
I'm working on a multi-tenant ASP.NET MVC application. So far we have been using
I have been working on a Meteor app and want to add multi-page functionality
I have been working on this a while. I see multi-dimensional arrays in php
I have jQuery menu I've been working on based on Stu Nicholls CSS multi-level
I have been unable to find a tutorial helping with multi-selects using cursors. As
I have a multi-tier Azure application I've been working on. It uses web and
I'm currently working on a multi-step query form which can be found at: http://jsfiddle.net/xSkgH/47/
Have been working on this question for a couple hours and have come close
I have been working with SQL Server as a Developer a while. One thing

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.