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 981387
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T04:32:08+00:00 2026-05-16T04:32:08+00:00

Let’s say you had a web app where people could submit links, links for

  • 0

Let’s say you had a web app where people could submit links, links for their own websites and links for website’s that they don’t own. The submission form is pretty much the same in both cases except when they submit the domain of the link.

If the user is submitting from a list of their own registered websites, they’d get a drop-down list of their websites.

If the user is submitting a link the user types the domain into a field whose value I get in the “link” model through an attr_accessor. The “link” model then executes a find_or_create method on that domain.

Right now my solution is unsatisfactory:
When the user clicks “Submit Link” I put ?other=prompt into the url and then have this kind of conditional:

<% if params[:other] == "prompt" %>
    <div class="prompt_form">

<h2>This link is for:</h2>
<span class="blue_button"><%= link_to "My Website", new_link_path%></span> <span class="blue_button"><%= link_to "Another User's Site", new_link_path(:other => "yes")%></span>
</p>

When the user makes a choice between the two options in the form renders differently:

<% if params[:other] == "yes" || current_user == nil %>
                    <strong>Website Domain:</strong><br />
                    <%= f.text_field :unclaimed_domain %><br />
            <% elsif current_user %>         
                <% if current_user.websites.size > 1 %>
                    <p>
                        <strong>Website Domain:</strong><br />
                        <%= f.collection_select :website_id, current_user.websites.valid, :id, :domain, {:include_blank => true}  %> <%= error_message_on :link, :website %><br />
                        <%= link_to "Add a Website", new_website_path %>
                    </p>
                <% else %>
                    <p>
                        <strong>Website Domain:</strong><br />
                        <%= f.collection_select :website_id, current_user.websites.valid, :id, :domain %><br />
                        <%= link_to "Add a Website", new_website_path %>
                    </p>
                <% end %>

The problem with this is that if the user makes an error and fails some validations, the “render :action => ‘new'” code gets executed and all the info in the params gets lost. Is there a way to keep that info or perhaps a different way to do this altogether?

  • 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-05-16T04:32:09+00:00Added an answer on May 16, 2026 at 4:32 am

    I have only vague understanding of your problem, but it seems you want this:

    <input name="other" value="<%= params[:other] %>" type="hidden">
    

    This way, current value of other will be resubmitted, and, if validation fails, it’ll still be accessible.

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

Sidebar

Related Questions

Let say I want to create an iOS app that download music files from
Let's say I have this element for displaying the website logo: <div id="web-title"> <a
Let's say I'm building an app that displays a UITableView of contacts. The user's
Let's say I have my own website, my own database and I want to
Let me explain best with an example. Say you have node class that can
Let me try to explain by example. Say website is hosted at example.com (NOT
Let's say that I have a SQLite database that I create in a separate
Let's say I have two text files that I need to extract data out
Let's say I have some text as follows: do this, do that, then this,
Let's say I have deployed my Rails app on a VPS, and everything works

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.