Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

Strange rails rendering problem - Rails Nested Form Builder select not rendering corInclude a specific error, task, problem, or question in your title

rails

This topic has been archived. This means that you cannot reply to this topic.
No replies to this topic

#1 chili5

chili5

    CC Mentor

  • Expert Member
  • PipPipPipPipPipPipPipPip
  • 3038 posts

Posted 09 May 2015 - 09:46 PM

Ignore that I screwed up the title XD

 

I'm encountering a really confusing Rendering error in rails that I can't explain. Maybe somebody has an idea?

 

When I run my code on a local rails server the following code isn't properly rendering the HTML. Yet, when I run it on a deployed server it renders correctly. The only difference I can find is that locally the server is WebBrick and the deployed server is Passenger. On both servers the version of the NestedForm gem is 0.32. I've checked and all code (all gems and my code) is exactly the same.

class BackupAndRestore < ActiveRecord::Base
  def backup_options
    [
      ["Backup", "Backup"],
      ["Restore", "Restore"]
    ]
  end

end 

<%= f.select(:backup_or_restore, options_for_select(@backup_and_restore.backup_options),{},{class: 'form-control input-sm'}) %>
 
 
 

The HTML output on web brick is:

 <select id="backup_or_restore_<option value=&quot;Backup&quot;>Backup</option><option value=&quot;Restore&quot;>Restore</option>" name="backup_or_restore[<option value=&quot;Backup&quot;>Backup</option><option value=&quot;Restore&quot;>Restore</option>]"></select>
Notice how the options are rendered in the id and name attributes and no CSS classes rendered?
 

 

On the passenger server:

<select class="form-control input-sm" id="backup_and_restore_backup_or_restore" name="backup_and_restore[backup_or_restore]"><option value="Backup">Backup</option><option value="Restore">Restore</option></select>
 

Any thoughts? Only thought is it's some difference in the servers ?


Edited by chili5, 09 May 2015 - 09:48 PM.