Note that there are some explanatory texts on larger screens.

plurals
  1. PO<Rails> Page format falls apart when rendering
    primarykey
    data
    text
    <p>I created a sample app to play around with rails. I'm having trouble with the page format of my site when a page is rendered. The text fields moves out of place from it's previous position and the format is just ruined. Please see the <a href="https://stackoverflow.com/questions/5267998/rails-3-field-with-errors-wrapper-changes-the-page-appearance-how-to-avoid-t">site</a> and just click the button and you'll see what I'm talking about.</p> <p>Here is my controller:</p> <pre><code>class BooksController &lt; ApplicationController def new @books = Book.new end def show end def create @books = Book.new(book_params) if @books.save redirect_to new_book_path, :flash =&gt; { :success =&gt; "Book Added"} else render 'new' end end def update end def edit end def destroy end private def book_params params.require(:book).permit(:title, :author, :genre, :no_of_items) end end </code></pre> <p>here my views/new.html.erb</p> <pre><code>&lt;h1&gt;Books#new&lt;/h1&gt; &lt;p&gt;Find me in app/views/books/new.html.erb&lt;/p&gt; &lt;% flash.each do |key, value|%&gt; &lt;div class="flash &lt;%= key %&gt;"&gt;&lt;%= value %&gt;&lt;/div&gt; &lt;% end %&gt; &lt;div class="form-horizontal"&gt; &lt;div class="control-group row-fluid form-inline"&gt; &lt;%= form_for @books do |f| %&gt; &lt;%= render 'shared/error_message' %&gt; &lt;p&gt; &lt;div class="fields"&gt; &lt;%= f.label :title, "Title:"%&gt; &lt;%= f.text_field :title %&gt;&lt;br/&gt;&lt;br/&gt; &lt;/div&gt; &lt;div class="fields"&gt; &lt;%= f.label :author, "Author:" %&gt; &lt;%= f.text_field :author %&gt;&lt;br/&gt;&lt;br/&gt; &lt;/div&gt; &lt;div class="fields"&gt; &lt;%= f.label :no_of_items, "No. of Items:" %&gt; &lt;%= f.text_field :no_of_items%&gt;&lt;br/&gt;&lt;br/&gt; &lt;/div&gt; &lt;div class="fields"&gt; &lt;%= f.label :genre, "Genre:" %&gt; &lt;%= f.text_field :genre%&gt;&lt;br/&gt;&lt;br/&gt; &lt;/div&gt; &lt;p&gt; &lt;%= submit_tag "Add book"%&gt; &lt;/p&gt; &lt;/p&gt; &lt;% end %&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>Can anyone help me tell what's happening and a fix for this? Thanks.</p> <p><strong>ANSWER:</strong> Hi everyone thanks for the advises but I found out through <a href="https://stackoverflow.com/questions/5267998/rails-3-field-with-errors-wrapper-changes-the-page-appearance-how-to-avoid-t">Rails 3: &quot;field-with-errors&quot; wrapper changes the page appearance. How to avoid this?</a> thread how to fix this problem. I can't answer my question within 6 hours so I'll answer this after the restriction has ended.</p>
    singulars
    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.
 

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