Git Product home page Git Product logo

wicked's People

Contributors

aaronmcadam avatar ahorner avatar bo-oz avatar bshelton229 avatar chocksy avatar deepakmahakale avatar drewhoffer avatar frozenfung avatar fschwahn avatar gokure avatar hwo411 avatar interhive avatar iseth avatar lucatironi avatar michael-garland avatar michaeldowse avatar mishina2228 avatar nruth avatar parndt avatar petergoldstein avatar pragmaticivan avatar racheldonovan avatar rcmc2 avatar reinaris avatar robertaudi avatar schneems avatar seanahrens avatar sirwolfgang avatar stve avatar twalpole avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

wicked's Issues

uninitialized constant Wicked::Wizard

Getting the following error when using a namespaced controller.

uninitialized constant Wicked::Wizard

The following makes no difference either:
::Wicked::Wizard

update: render_wizard

is there a way to render back to the show step?

def update
  case step
  when :accept_terms
      if not params[:terms]
        ----> redirect to show step :accept_terms

?

render_wizard/redirect_to accept_terms path results in a redirect loop :-(

save method called twice

In the example you provide:

class AfterSignupController < ApplicationController
  include Wicked::Wizard

  steps :confirm_password, :confirm_profile, :find_friends

  def update
    @user = current_user
    case step
    when :confirm_password
      @user.update_attributes(params[:user])
    end
    sign_in(@user, :bypass => true) # needed for devise
    render_wizard @user
  end
end

On the confirm_password step, you are calling update_attributes which is calling the save method on the user.
Then, in render_wizard @user, the process_resource! method is being called on the user resource, which also calls the save method.

As a consequence, it looks like 2 transactions are being made and model callbacks are being called twice.

Any idea if I am doing something stupid or what should be done to avoid having callbacks called twice?

Thanks!

Wizard paths with object IDs

I'm not sure how to use Wicked with paths like:

/controller/:id/wizard_step

The situation is that I want to create a new product:

/products/new

Save a new object and redirect to the wizard to populate its data:

/products/1/step_1
/products/1/step_2
etc.

undefined method `include?'

I'm getting:

undefined method `include?' for nil:NilClass

Class User
  def active_or_address?
  status.include?('address') || active?
end

Full Trace

NoMethodError in RegistrationsController#create

undefined method `include?' for nil:NilClass
Rails.root: /Users/nelsonkeating/Desktop/remindeal1

Application Trace | Framework Trace | Full Trace
app/models/user.rb:54:in active_or_address?' /gems/activesupport-3.2.3/lib/active_support/callbacks.rb:524:in_run__4539920570864256223__validate__3874024522057665424__callbacks'
/gems/activesupport-3.2.3/lib/active_support/callbacks.rb:405:in __run_callback' /gems/activesupport-3.2.3/lib/active_support/callbacks.rb:385:in_run_validate_callbacks'
/gems/activesupport-3.2.3/lib/active_support/callbacks.rb:81:in run_callbacks' /gems/activemodel-3.2.3/lib/active_model/validations.rb:212:inrun_validations!'
/gems/activemodel-3.2.3/lib/active_model/validations/callbacks.rb:53:in block in run_validations!' /gems/activesupport-3.2.3/lib/active_support/callbacks.rb:425:in_run__4539920570864256223__validation__3874024522057665424__callbacks'
/gems/activesupport-3.2.3/lib/active_support/callbacks.rb:405:in __run_callback' /gems/activesupport-3.2.3/lib/active_support/callbacks.rb:385:in_run_validation_callbacks'
/gems/activesupport-3.2.3/lib/active_support/callbacks.rb:81:in run_callbacks' /gems/activemodel-3.2.3/lib/active_model/validations/callbacks.rb:53:inrun_validations!'
/gems/activemodel-3.2.3/lib/active_model/validations.rb:179:in valid?' /gems/activerecord-3.2.3/lib/active_record/validations.rb:69:invalid?'
/gems/activerecord-3.2.3/lib/active_record/validations.rb:77:in perform_validations' /gems/activerecord-3.2.3/lib/active_record/validations.rb:50:insave'
/gems/activerecord-3.2.3/lib/active_record/attribute_methods/dirty.rb:22:in save' /gems/activerecord-3.2.3/lib/active_record/transactions.rb:241:inblock (2 levels) in save'
/gems/activerecord-3.2.3/lib/active_record/transactions.rb:295:in block in with_transaction_returning_status' /gems/activerecord-3.2.3/lib/active_record/connection_adapters/abstract/database_statements.rb:192:intransaction'
/gems/activerecord-3.2.3/lib/active_record/transactions.rb:208:in transaction' /gems/newrelic_rpm-3.3.5/lib/new_relic/agent/method_tracer.rb:491:inblock in transaction_with_trace_ActiveRecord_self_name_transaction'
/gems/newrelic_rpm-3.3.5/lib/new_relic/agent/method_tracer.rb:242:in trace_execution_scoped' /gems/newrelic_rpm-3.3.5/lib/new_relic/agent/method_tracer.rb:486:intransaction_with_trace_ActiveRecord_self_name_transaction'
/gems/activerecord-3.2.3/lib/active_record/transactions.rb:293:in with_transaction_returning_status' /gems/activerecord-3.2.3/lib/active_record/transactions.rb:241:inblock in save'
/gems/activerecord-3.2.3/lib/active_record/transactions.rb:252:in rollback_active_record_state!' /gems/activerecord-3.2.3/lib/active_record/transactions.rb:240:insave'
/gems/devise-2.1.1/app/controllers/devise/registrations_controller.rb:15:in create' /gems/actionpack-3.2.3/lib/action_controller/metal/implicit_render.rb:4:insend_action'
/gems/actionpack-3.2.3/lib/abstract_controller/base.rb:167:in process_action' /gems/actionpack-3.2.3/lib/action_controller/metal/rendering.rb:10:inprocess_action'
/gems/actionpack-3.2.3/lib/abstract_controller/callbacks.rb:18:in block in process_action' /gems/activesupport-3.2.3/lib/active_support/callbacks.rb:447:in_run__3859976134561150154__process_action__1006715421838506127__callbacks'
/gems/activesupport-3.2.3/lib/active_support/callbacks.rb:405:in __run_callback' /gems/activesupport-3.2.3/lib/active_support/callbacks.rb:385:in_run_process_action_callbacks'
/gems/activesupport-3.2.3/lib/active_support/callbacks.rb:81:in run_callbacks' /gems/actionpack-3.2.3/lib/abstract_controller/callbacks.rb:17:inprocess_action'
/gems/actionpack-3.2.3/lib/action_controller/metal/rescue.rb:29:in process_action' /gems/actionpack-3.2.3/lib/action_controller/metal/instrumentation.rb:30:inblock in process_action'
/gems/activesupport-3.2.3/lib/active_support/notifications.rb:123:in block in instrument' /gems/activesupport-3.2.3/lib/active_support/notifications/instrumenter.rb:20:ininstrument'
/gems/activesupport-3.2.3/lib/active_support/notifications.rb:123:in instrument' /gems/actionpack-3.2.3/lib/action_controller/metal/instrumentation.rb:29:inprocess_action'
/gems/actionpack-3.2.3/lib/action_controller/metal/params_wrapper.rb:205:in process_action' /gems/activerecord-3.2.3/lib/active_record/railties/controller_runtime.rb:18:inprocess_action'
/gems/newrelic_rpm-3.3.5/lib/new_relic/agent/instrumentation/rails3/action_controller.rb:34:in block in process_action' /gems/newrelic_rpm-3.3.5/lib/new_relic/agent/instrumentation/controller_instrumentation.rb:257:inblock in perform_action_with_newrelic_trace'
/gems/newrelic_rpm-3.3.5/lib/new_relic/agent/method_tracer.rb:242:in trace_execution_scoped' /gems/newrelic_rpm-3.3.5/lib/new_relic/agent/instrumentation/controller_instrumentation.rb:252:inperform_action_with_newrelic_trace'
/gems/newrelic_rpm-3.3.5/lib/new_relic/agent/instrumentation/rails3/action_controller.rb:33:in process_action' /gems/actionpack-3.2.3/lib/abstract_controller/base.rb:121:inprocess'
/gems/actionpack-3.2.3/lib/abstract_controller/rendering.rb:45:in process' /gems/actionpack-3.2.3/lib/action_controller/metal.rb:203:indispatch'
/gems/actionpack-3.2.3/lib/action_controller/metal/rack_delegation.rb:14:in dispatch' /gems/actionpack-3.2.3/lib/action_controller/metal.rb:246:inblock in action'
/gems/actionpack-3.2.3/lib/action_dispatch/routing/route_set.rb:73:in call' /gems/actionpack-3.2.3/lib/action_dispatch/routing/route_set.rb:73:indispatch'
/gems/actionpack-3.2.3/lib/action_dispatch/routing/route_set.rb:36:in call' /gems/actionpack-3.2.3/lib/action_dispatch/routing/mapper.rb:40:incall'
/gems/journey-1.0.4/lib/journey/router.rb:68:in block in call' /gems/journey-1.0.4/lib/journey/router.rb:56:ineach'
/gems/journey-1.0.4/lib/journey/router.rb:56:in call' /gems/actionpack-3.2.3/lib/action_dispatch/routing/route_set.rb:600:incall'
/gems/sass-3.1.19/lib/sass/plugin/rack.rb:54:in call' /gems/newrelic_rpm-3.3.5/lib/new_relic/rack/browser_monitoring.rb:12:incall'
/gems/newrelic_rpm-3.3.5/lib/new_relic/rack/developer_mode.rb:24:in call' /gems/client_side_validations-3.1.4/lib/client_side_validations/middleware.rb:18:incall'
/gems/warden-1.2.1/lib/warden/manager.rb:35:in block in call' /gems/warden-1.2.1/lib/warden/manager.rb:34:incatch'
/gems/warden-1.2.1/lib/warden/manager.rb:34:in call' /gems/actionpack-3.2.3/lib/action_dispatch/middleware/best_standards_support.rb:17:incall'
/gems/rack-1.4.1/lib/rack/etag.rb:23:in call' /gems/rack-1.4.1/lib/rack/conditionalget.rb:35:incall'
/gems/actionpack-3.2.3/lib/action_dispatch/middleware/head.rb:14:in call' /gems/actionpack-3.2.3/lib/action_dispatch/middleware/params_parser.rb:21:incall'
/gems/actionpack-3.2.3/lib/action_dispatch/middleware/flash.rb:242:in call' /gems/rack-1.4.1/lib/rack/session/abstract/id.rb:205:incontext'
/gems/rack-1.4.1/lib/rack/session/abstract/id.rb:200:in call' /gems/actionpack-3.2.3/lib/action_dispatch/middleware/cookies.rb:338:incall'
/gems/activerecord-3.2.3/lib/active_record/query_cache.rb:64:in call' /gems/activerecord-3.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:467:incall'
/gems/actionpack-3.2.3/lib/action_dispatch/middleware/callbacks.rb:28:in block in call' /gems/activesupport-3.2.3/lib/active_support/callbacks.rb:405:in_run__1050537933734709659__call__3874024522057665424__callbacks'
/gems/activesupport-3.2.3/lib/active_support/callbacks.rb:405:in __run_callback' /gems/activesupport-3.2.3/lib/active_support/callbacks.rb:385:in_run_call_callbacks'
/gems/activesupport-3.2.3/lib/active_support/callbacks.rb:81:in run_callbacks' /gems/actionpack-3.2.3/lib/action_dispatch/middleware/callbacks.rb:27:incall'
/gems/actionpack-3.2.3/lib/action_dispatch/middleware/reloader.rb:65:in call' /gems/actionpack-3.2.3/lib/action_dispatch/middleware/remote_ip.rb:31:incall'
/gems/actionpack-3.2.3/lib/action_dispatch/middleware/debug_exceptions.rb:16:in call' /gems/actionpack-3.2.3/lib/action_dispatch/middleware/show_exceptions.rb:56:incall'
/gems/railties-3.2.3/lib/rails/rack/logger.rb:26:in call_app' /gems/railties-3.2.3/lib/rails/rack/logger.rb:16:incall'
/gems/actionpack-3.2.3/lib/action_dispatch/middleware/request_id.rb:22:in call' /gems/rack-1.4.1/lib/rack/methodoverride.rb:21:incall'
/gems/rack-1.4.1/lib/rack/runtime.rb:17:in call' /gems/activesupport-3.2.3/lib/active_support/cache/strategy/local_cache.rb:72:incall'
/gems/rack-1.4.1/lib/rack/lock.rb:15:in call' /gems/actionpack-3.2.3/lib/action_dispatch/middleware/static.rb:62:incall'
/gems/railties-3.2.3/lib/rails/engine.rb:479:in call' /gems/railties-3.2.3/lib/rails/application.rb:220:incall'
/gems/rack-1.4.1/lib/rack/content_length.rb:14:in call' /gems/railties-3.2.3/lib/rails/rack/log_tailer.rb:14:incall'
/gems/thin-1.3.1/lib/thin/connection.rb:80:in block in pre_process' /gems/thin-1.3.1/lib/thin/connection.rb:78:incatch'
/gems/thin-1.3.1/lib/thin/connection.rb:78:in pre_process' /gems/thin-1.3.1/lib/thin/connection.rb:53:inprocess'
/gems/thin-1.3.1/lib/thin/connection.rb:38:in receive_data' /gems/eventmachine-0.12.10/lib/eventmachine.rb:256:inrun_machine'
/gems/eventmachine-0.12.10/lib/eventmachine.rb:256:in run' /gems/thin-1.3.1/lib/thin/backends/base.rb:61:instart'
/gems/thin-1.3.1/lib/thin/server.rb:159:in start' /gems/rack-1.4.1/lib/rack/handler/thin.rb:13:inrun'
/gems/rack-1.4.1/lib/rack/server.rb:265:in start' /gems/railties-3.2.3/lib/rails/commands/server.rb:70:instart'
/gems/railties-3.2.3/lib/rails/commands.rb:55:in block in ' /gems/railties-3.2.3/lib/rails/commands.rb:50:intap'
/gems/railties-3.2.3/lib/rails/commands.rb:50:in ' script/rails:6:inrequire'
script/rails:6:in `'

Validations for Partial Objects

With sexy validations in Rails less redundant validations are possible.

validates :foo, :presence_on_step_or_active => {:step => :first}
def active?
    ...
end

# populate with current step in controller
attr_accessor :wicked_step 
class PresenceOnStepOrActiveValidator < ActiveModel::Validator
  def validate(record)
    if options[:step] == record.wicked_step || record.active?
      record.errors.add_on_blank(options[:attributes])
    end
  end
end

wicked_step could possibly be put in a more accessible place and be set in the setup_wizard before filter.

Dynamic steps error

class ProfilesController < ApplicationController
  include Wicked::Wizard

  prepend_before_filter :set_my_steps

   def set_my_steps
     if !current_user.student?
       self.class.steps :foo, :bar, :baz
     else
       self.class.steps :bar, :baz, :foo
     end
   end

Don't work - says "undefined method `first' for nil:NilClass"

Error from: wicked (0.2.0) lib/wicked/wizard.rb:29:in `setup_wizard'

What it's can be? Thx

Set custom layout for render_wizard

How can i set a custom layout for the wizard steps?

i don't want to use the application.html.erb layout, so i create another, but how can i tell to render_wizard to use the new layout?

question: to pass an array of steps..

Thanks for your project! I realize this might involve metaprogramming, but I'm wonder if you happen to know if it's possible to pass an array of symbols to the steps method in a controller. e.g.:

PRODUCT_STEPS = [:step1, :step2, :step3]
steps PRODUCT_STEPS

Using next_wizard_path, previous_wizard_path etc but saving document in between

So I might not understand the process fully, but I like this solution for something I am working on. It is a wizard format questionnaire really that you can goto a page defined in wicked, complete some radio boxes (all that are in a form) save the document and it goes to the next step in the questionnaire. This is all working great, but I want the user to jump around ( I realize this breaks the wizard-ness of it but this is by far the best solution for what I am trying to do). So I have a nice header iwth three links:

HOME NEXT PREVIOUS
all using the next_wizard_path, previous_wizard_path and then the one that goes directly to home:
wizard_path(:doc_home)

this works great as well, the biggest issue I have though is it calls a show not an update so I cannot figure out how to take the current form items and save them to the db before going to the next_wizard_path, not even sure what direction id look into to do this...the green-ness of my rails is showing here but I am sure there has to be a way, i want to continue to use wicked as my solution this is the only thing perplexing me thus far.

previous_wizard_path not recognized

Hi - awesome project. Thank you.

Everything works except for this one feature. The system doesn't have it defined. My workaround is to use wizard_path() with the step explicitly given.

Add skip_step into readme

Hello

Firstly, sorry if my english is a little bit wrong, and because I'm don't know anymore how to do a pull request, I'll write thing that could be upgrade

It could be great if skip_step is also referenced into Quick Reference - Controller Tidbits.

More, I would prefere to order Quick Reference as if we have
'View helper' (mainly the path helper) (already correct),
'Controller helper' (with render helper and skip helper) and
'Global helper' (with step and wizard_steps helper).

Personally, i was looking reference into that order.

Thanks

Redirect back to the last step

In my application user has to filled 7 steps for Visit model. But he can choose to exit from any step but if that user is coming back I want to show him what was his last step and redirect him there.

I tried to set a value for step but its not working

Handling instance variables

Hi,
I have a multi-step wizard with many instance variables per step (like 6-7 for each step, many of them options for dropdown selects). Is there a best practice to handle this variables? (considering I'll move to wicked to render the multi-step form)

Thanks in advance,

Forward params passed to the :finish step

The :finish step is redirecting to the show step but not forwarding the params that it needs.

def show
  @asset = Asset.find(params[:asset_id])
  @team = @asset.team
  render_wizard
end

Mongoid EMBEDDED 1-1 not working

Hello, thanks for this gem, it's awesome.

I've got little problem with Mongoid relation embedded 1-1. This 1-1 relation isn't building resource (current_order.build_address) in wicked controller. But when I try to build it in my (for example application) controller it is working as excepted.

My wizard controller:

class OrderController < ApplicationController
  include Wicked::Wizard

  steps :cart, :address, :shipping, :summary

  def show
    current_order.build_address
    render_wizard
  end
end

My Address model:

class Address
  include Mongoid::Document

  field :city

  embedded_in :order
end

My Order model:

class Order
  include Mongoid::Document

  embeds_one :address

  accepts_nested_attributes_for :address
end

Wicked form:

= form_for current_order, url: wizard_path do |f|
  = f.fields_for :address do |ff|
    = ff.text_field :city
  = f.submit

Inconsistency with step translations

When using the translation feature, you get a problematic inconsistency: while the step names in the steps array are translated, the name returned by step is the original name. This makes it a bit harder to to calculate progress and use the "case step" paradigm consistently etc..

It would be nice, if either both steps and step contained either the original (which I would prefer) or the translated step names.

Cheers
Michael

Creating POST routes for wicked

(Apologies in advance, this is more a question than a bug)

I have created a 'widget' using Wicked that I'm trying to use in a Facebook Canvas App.

Facebook calls the specified URL with POST as opposed to GET, so it searches for an action with the name of the 'step' instead of the show action, resulting in a 500 error.

Can you think of a workaround for this?

I'm thinking I might be able to create an action for each step name, and redirect as appropriate, but that'd be pretty ugly.

Thanks for the great gem!

blocking non-relevant fields in a step

Ok, I don't know if you have an easy solution for this situation:
Let's say I have something like this with two steps defined in my controller:
where, e.g: I validate fieldA if I'm on stepA and I validate fieldB if I'm on stepB (you could imagine I do the same pattern for C,D, etc..)

class Products::BuildController < PrivateController
    steps :stepA, :stepB, stepC, stepD
end


class Product < ActiveRecord::Base
  validates :fieldA, :inclusion => {:in => 0..10}, :if => :active_or_on_stepA?
  validates :fieldB, :inclusion => {:in => 11..20}, :if => :active_or_on_stepB?

  def active?
    self.status == "active"
  end

  def active_or_on_stepA?
    self.status == "stepA" || active?
  end

  def active_or_on_stepB?
    self.status == "stepB" || active?
  end
end

ok, now let's say (evil) hacker, Mallory is able to inject fieldA to step B. (and saves an evil value for fieldA :)). Mallory then submits the rogue value in stepB.. (maybe storing -100 for fieldA in stepB).
.. then the database would store the updated/rogue fieldA when the user is e.g: then on stepC.

I wonder if you know a good way to stop that from happening. (I realize that moving to the active state would eventually fail/die but e.g: while stepC and stepD are occurring, corrupted values could be in the database).

Any ideas on this? Thanks!

redirect_to_finish_wizard

Hey, great gem and it works great for me, too.

I do not want to redirect to root_url and thus would like to use the
def redirect_to_finish_wizard. I copied it from the example but unfortunately it throws me an error:

wrong number of arguments (1 for 0)
app/controllers/event_steps_controller.rb:18:in redirect_to_finish_wizard' app/controllers/event_steps_controller.rb:7:inshow'
{"id"=>"finish"}

I am pretty sure it has nothing to do with the gem but for the moment I am really stuck. So, thx for any help.

Stay on step if no field has input

Hey,

I'm trying wicked out and it has been great so far.
But my Rails/Ruby knowledge is letting me down right now and hopefully someone could help me here.

I have a little case in my update method.
At a certain step I want to check if there has been any valid input, if there isn't any input I want to stay on this step and don't go further.
Something along these lines:

def update
case step
when :order_articles
@order.add_amount_to_order_lines!(params[:order_lines])

  if [email protected]_valid_order_lines?
     #stay on the same step don't go further!
  end

end

render_wizard @order
end

Any idea how I can solve this problem?
Thanks a lot in advance

Niels

don't require inheriting from gem's controller

It would be better if using the gem didn't require inheriting from the gem's controller - Rails apps usually have an ApplicationController that contains lots of common configuration and helpers, and if you're not inheriting from that, you'll have to duplicate some of that code in the wizard controller.

Routing error when wicked controllers are namespaced.

Whenever I try to namespace my wicked controllers I always get routing errors, and can't seem to find any documentation regarding how one would pull it off.

My routes.rb looks like this:

resources :setup, controller: 'Wizards::AfterSignup'

But always the error

No route matches {:controller=>"wizards/after_signup", :action=>"show", :id=>"subscription"}

Rails 4 compatibility

I started a Rails 4 app and attempted to integrate wicked. Rails appears to be looking for a "show" template instead of the template with the step name.

I'm in a namespaced controller which i haven't used with wicked before, so potentially that is the issue instead, but the Rails 4 upgrade seemed more likely

#routes.rb
  namespace :profiles do
    resources :setup
  end
# app/controllers/profiles/setup_controller
class Profiles::SetupController < ApplicationController
  include Wicked::Wizard
  steps :bio

  def show
  end

  def edit
  end
end
#error
ActionView::MissingTemplate (Missing template profiles/setup/show, application/show with {:locale=>[:en], :formats=>[:html], :handlers=>[:erb, :builder, :raw, :ruby, :coffee]}.

wizard for remote forms

I use wicked gem in a situation where I use remote form for both the create action and for the other steps in the wizard
I cannot figure out how to make remote forms work in this context

I have the steps steps :course_description, :targeted_groups, :sub_targets
I am using new.js for the first step that uses the controller courses_controller and have tried targeted_groups,js loading the partial _targeted_groups.html for the second step using courses_wizard_controllerand.
I have also tried show.js loading the same partial but both these attemps failed.

How to use wicked with remote forms?
Is it possible ?
Is there any workaround if not ?

302 Moved Temporarily response from ajax form

Hi there,

I'm wondering if you can help me, I'm using your Wicked gem and sending the form via AJAX, but always seem to get the response: 302 Moved Temporarily, in our controller we've got:

format.html { redirect_to project_step_path("todos") }
format.js { redirect_to project_step_path("todos") }
format.json { redirect_to project_step_path("todos") }

"todos" being the first step of the wizard.

It does work perfectly without ajax.

It looks to me as if the response never gets to the project_steps_controller

If you are able to help, that'll be great :D

cheers
CHRXS

Dynamic steps

Feature request/advice

New rails developer here. Is it possible to dynamically define the wizard steps? I'm writing an interface for economics experiment, and I'd like to vary the order of the wizard based on the "type" of user visiting the controller. I don't think this would work (I'm not within an action with @user defined, don't know if I can do that outside an action):

  class FooController < ApplicationController
    include Wicked::Wizard

    if @user.type == 1
      steps :foo, :bar, :baz
    elsif @user.type ==2
      steps :bar, :baz, :foo

How would you approach this problem?

render_wizard extra param

Hi, I can not add an extra params to render_wizard method, in order to accomplish this i have

render_wizard(@channel, {:distributor_id => @distributor.id})

but I just redirect to the next step without the distributor_id params.
Have i anything wrong in my syntax?
Thank you

double redirect when wizard is finished

Hi again,
so I stumbled upon another 'issue'. When render_wizard is called with a resource when the last step is reached, a redirect occurs to /controller/finish, which issues another redirect to whatever is defined in finish_wizard_path. Is there any reason to do this? Would it make sense to directly redirect to whatever is defined in finish_wizard_path when the last step is reached?

In my case I need to redirect based on the resource, but it is 'lost' when the redirect to the finish step happens. I can think of several workarounds, but this double redirect seems unnecessary anyway.

What do you think?

Best regards,
Fabian

wizard_path doesn't do anything useful for unsaved records

I'm trying to do a wizard for creating a new entry (profile) in an app where one user has many profiles.

    # Migration
    create_table :profiles do |t|

      t.integer :user_id,    null: false
      t.string  :name,       null: false, limit: 100

      t.boolean :visible,    null: false, default: false

      t.integer :age
      t.integer :height
      t.integer :weight

   end

I have migrations akin to those you recommend in the blog post about multi-step form validation, which I imagine works quite well, however the problem is:

<form accept-charset="UTF-8" action="/assets?action=show&amp;controller=profile" class="form-horizontal" id="new_profile" method="post">

This doesn't seem to be related to whether the model is saved or not, and I'm having a hard time to understand what I might be doing wrong.

= form_for profile, url: wizard_path, html: {class: 'form-horizontal'} do |f|
  = h profile.inspect
  %fieldset
    = yield f

Note: Opening as a bug, because whatever I'm doing is non-obvious and I'd expect an exception if I've done something that wizard_path doesn't understand.

On interrupted Signups

Hey guys-

So i'm working on a site where I want users to be sent back to the sign-up step they're currently "on", while that's easy from within the wizard's controller, I'd like to interrupt other paths / pages pretty globally..using a before_filter in the app controller currently.

My current plan is to do something like:

redirect_to welcome_path(:step1) and return if current_user.steps_complete = 0
etc...

But that's pretty ugly, and the steps_complete method will be fragile. I wish welcome_path(:current_step) worked but it doesn't.. is there a smarter way to do this that I'm missing?

jump_to call ignored if render_wizard is called with resource

Hi,
first of all thanks for this great gem, it makes working with wizard really much easier.
When I'm using jump_to prior to using render_wizard(@resource), the @skip_to variable is overwritten, and the next step is rendered. This is expected behavior according to the README, but I think it would be better if render_wizard checks if @skip_to is set, and honors also when a resource is passed.

I'd be happy to put together a PR if you are interested.

Best regards,
Fabian

Dynamic Steps - undefined method `index' for nil:NilClass

This doesn't seem to work:

class SplitSharesController < ApplicationController
  include Wicked::Wizard

  before_filter :set_steps

  def show
   #snip
  end

  def update
   #snip
  end

  def finish_wizard_path
   #snip
  end

private
  def set_steps
    case params[:transaction_type]
    when 'split'
      steps = :split_details, :confirmation
    when 'consolidate'
      steps = :consolidate_details, :confirmation        
    end
  end
end

The error I get is:

NoMethodError in SplitSharesController#show

undefined method `index' for nil:NilClass

Any ideas on how to set the steps dynamically based on a url parameter? I want to encapsulate several similar transaction types in a single wizard as they share the same concern and would rather not have a ton of very similar wizard controllers.

A mistake in a wizard_value method

In lib/wicked/wizard/translated.rb there is such method:

def wizard_value(step_name)
    wizard_translations[step]
end

As u see wizard_translations take step and not step_name as argument.
Correct implementation is

def wizard_value(step_name)
  wizard_translations[step_name]
end

Pls fix it

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.