Note that there are some explanatory texts on larger screens.

plurals
  1. PORoR, Jquery, Ajax form errors
    primarykey
    data
    text
    <p>Alright. I have a create form where people are able to create businesses which are then added to the database. Everything worked fine. Rails was throwing it's errors if things weren't filled out correctly and if they were, you;d be directed to another page that would show you the business you just created. Now with that, I have to be able to click create and have ajax implement the business and add it to the table below. Things are kind of working. 1 the business is updated but isn't dynamically added to the table. 2. the bigger problem, is that is they don't fill out the required fields, clicking create does nothing. It doesn't throw any of the errors. I'm using jquery to call the ajax through .js.erb files. Here's my .js.erb file.</p> <pre><code>$("#new_business").before('&lt;div id="flash_notice"&gt;&lt;%= escape_javascript(flash.delete(:notice)) %&gt;&lt;/div&gt;'); $("#businesses").append("&lt;%= escape_javascript(render(:partial =&gt; @businesses)) %&gt;"); $("#new_business")[0].reset(); </code></pre> <p>and my business controller</p> <pre><code> def create @business = Business.new(params[:business]) respond_to do |format| if @business.save #blindly make them the owner of the business they created if current_user current_user.business_id = @business.id current_user.save end flash.now[:notice] = 'Business was successfully created.' format.html { redirect_to(business_url(@business)) } format.js { render :layout =&gt; false } format.xml { render :xml =&gt; @business, :status =&gt; :created, :location =&gt; @business } else flash.now[:notice] = 'Necessary fields have not been filled out' format.html { render :action =&gt; "new" } format.xml { render :xml =&gt; @business.errors, :status =&gt; :unprocessable_entity } end end end </code></pre> <p>The flash notice = Necessary fields have not been filled out doesn't show up unless you refresh the page. None of the default xml errors are showing up either. so if they don't fill out all the correct forms, the button seems unresponsive. How do I use ajax to call those errors ruby is throwing and put them into the flash notice?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload