David Kimura PRO
Joined 7/18/2015
Drifting Ruby Owner
Ruby Rogues Panelist
David Kimura PRO said over 3 years ago on Form Wizards from Scratch :
  I would handle this with the buttons as the names would have a commit param. I'm not sure how this would be handled in i18n land. I'd assume that you'd pass a value attribute on the form.submit with previous or continue.

    <%= form.submit "Previous", class: 'btn btn-secondary' %>
    <%= form.submit "Continue", class: 'btn btn-primary' %>


You can then navigate to the appropriate routes on the create action.

      def create
        @company_profile = CompanyProfile.new(company_profile_params)
        if @company_profile.valid?
          session[:company_profile] = {
            name: @company_profile.name,
            website: @company_profile.website
          }
          
          redirect_to redirection_url
        else
          render :new
        end
      end

      private

      def redirection_url
        case params[:commit]
        when "Continue"
          new_wizards_companies_location_path
        when "Previous
          new_wizards_companies_[PREVIOUS_RESOURCE_STEP_HERE]_path
        else
          # handle non matching (likely the next step)
        end
      end


David Kimura PRO said over 3 years ago on Cross-Origin Resource Sharing (CORS) :
  It looks like in your staging, landing_page and production block, you allow all origins

origins "*"

Could you set an environment variable in place and things work properly?

origins ENV["URL_DOMAIN"]

David Kimura PRO said over 3 years ago on Creating and Reading QR Codes :
A QR code is really just an encoded text. There isn't really any kind of data structure to it. So it can have text like the product name or a URL to it.

David Kimura PRO said over 3 years ago on Like Relationships and Global ID :
  Do you have the associations in your models?

  has_many :users_posts
  has_many :liked_posts, through: :users_posts, source: :post

You can then call user.liked_posts on your instance of the user.

David Kimura PRO said over 3 years ago on Like Relationships and Global ID :
  you're looping through all of the liked posts, so you would need to call post.to_sgid instead of @liked_post.to_sgid