![]() |
| Help Editing Record |
|
rdx73
|
I am new to Ruby. I am trying to update a table that only has one record with an id of 1. I get the following errors:
AdminController#edit_globals Couldn't find Globals without an ID RAILS_ROOT: ./script/../config/.. Application Trace | Framework Trace | Full Trace c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/base.rb:939:in `find_from_ids' c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/base.rb:382:in `find' #{RAILS_ROOT}/app/controllers/admin_controller.rb:143:in `edit_globals' c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/base.rb:939:in `find_from_ids' c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/base.rb:382:in `find' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/base.rb:941:in `send' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/base.rb:941:in `perform_action_without_filters' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/filters.rb:368:in `perform_action_without_benchmark' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/benchmarking.rb:69:in `perform_action_without_rescue' c:/ruby/lib/ruby/1.8/benchmark.rb:293:in `measure' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/benchmarking.rb:69:in `perform_action_without_rescue' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/rescue.rb:82:in `perform_action' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/base.rb:408:in `send' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/base.rb:408:in `process_without_filters' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/filters.rb:377:in `process_without_session_management_support' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/session_management.rb:117:in `process' c:/ruby/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/dispatcher.rb:38:in `dispatch' c:/ruby/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/webrick_server.rb:115:in `handle_dispatch' c:/ruby/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/webrick_server.rb:81:in `service' c:/ruby/lib/ruby/1.8/webrick/httpserver.rb:104:in `service' c:/ruby/lib/ruby/1.8/webrick/httpserver.rb:65:in `run' c:/ruby/lib/ruby/1.8/webrick/server.rb:173:in `start_thread' c:/ruby/lib/ruby/1.8/webrick/server.rb:162:in `start' c:/ruby/lib/ruby/1.8/webrick/server.rb:162:in `start_thread' c:/ruby/lib/ruby/1.8/webrick/server.rb:95:in `start' c:/ruby/lib/ruby/1.8/webrick/server.rb:92:in `each' c:/ruby/lib/ruby/1.8/webrick/server.rb:92:in `start' c:/ruby/lib/ruby/1.8/webrick/server.rb:23:in `start' c:/ruby/lib/ruby/1.8/webrick/server.rb:82:in `start' c:/ruby/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/webrick_server.rb:67:in `dispatch' c:/ruby/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/commands/servers/webrick.rb:59 c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require' c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require' c:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:147:in `require' c:/ruby/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/commands/server.rb:30 c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require' c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require' c:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:147:in `require' script/server:3 c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/base.rb:939:in `find_from_ids' c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/base.rb:382:in `find' #{RAILS_ROOT}/app/controllers/admin_controller.rb:143:in `edit_globals' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/base.rb:941:in `send' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/base.rb:941:in `perform_action_without_filters' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/filters.rb:368:in `perform_action_without_benchmark' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/benchmarking.rb:69:in `perform_action_without_rescue' c:/ruby/lib/ruby/1.8/benchmark.rb:293:in `measure' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/benchmarking.rb:69:in `perform_action_without_rescue' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/rescue.rb:82:in `perform_action' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/base.rb:408:in `send' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/base.rb:408:in `process_without_filters' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/filters.rb:377:in `process_without_session_management_support' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/session_management.rb:117:in `process' c:/ruby/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/dispatcher.rb:38:in `dispatch' c:/ruby/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/webrick_server.rb:115:in `handle_dispatch' c:/ruby/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/webrick_server.rb:81:in `service' c:/ruby/lib/ruby/1.8/webrick/httpserver.rb:104:in `service' c:/ruby/lib/ruby/1.8/webrick/httpserver.rb:65:in `run' c:/ruby/lib/ruby/1.8/webrick/server.rb:173:in `start_thread' c:/ruby/lib/ruby/1.8/webrick/server.rb:162:in `start' c:/ruby/lib/ruby/1.8/webrick/server.rb:162:in `start_thread' c:/ruby/lib/ruby/1.8/webrick/server.rb:95:in `start' c:/ruby/lib/ruby/1.8/webrick/server.rb:92:in `each' c:/ruby/lib/ruby/1.8/webrick/server.rb:92:in `start' c:/ruby/lib/ruby/1.8/webrick/server.rb:23:in `start' c:/ruby/lib/ruby/1.8/webrick/server.rb:82:in `start' c:/ruby/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/webrick_server.rb:67:in `dispatch' c:/ruby/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/commands/servers/webrick.rb:59 c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require' c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require' c:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:147:in `require' c:/ruby/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/commands/server.rb:30 c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require' c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require' c:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:147:in `require' script/server:3 Request Parameters: None Show session dump --- :cart: !ruby/object:Cart items: [] flash: !map:ActionController::Flash::FlashHash {} Response Headers: {"cookie"=>[], "Cache-Control"=>"no-cache"} Here is my edit_globals rhtml in views/admin: <script language="javascript" type="text/javascript" src="/javascripts/202pop.js"></script> <table width="98%" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td><script type="text/javascript" src="/javascripts/tabber.js"></script> <link rel="stylesheet" href="/stylesheets/example.css" TYPE="text/css" MEDIA="screen"> <script type="text/javascript"> /* Optional: Temporarily hide the "tabber" class so it does not "flash" on the page as plain HTML. After tabber runs, the class is changed to "tabberlive" and it will appear. */ document.write('<style type="text/css">.tabber{display:none;}<\/style>'); </script> <h2><strong>Edit Global Styles</strong></h2> <form action="../update_globals/<%=@globals.id %>" method="POST"><input id="categories_id" name="globals[id]" size="30" type="hidden" value="1" /> <div class="tabber"> <div class="tabbertab"> <table width="100%" border="0" cellpadding="0" cellspacing="0"> <tr> <td><h2>Body</h2> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td height="20" ><strong><font color="#000033">Edit Body Styles </font></strong></td> </tr> </table> Body BG Color <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="9%"><input name="globals[body_bg]" type="text" id="globals[body_bg]" value="<%=<%=@globals.body_bg%>%>" size="14"></td> <td width="91%"><A HREF="#" onclick="pickerPopup202('globals[body_bg]','sample_id');"><img src="/images/colorpicker.gif" width="21" height="21" border="0"></A></td> </tr> </table> Body BG Image<br> <input name="globals[body_bg_image]" type="text" id="globals[body_bg_image]" value="<%=@globals.body_bg_image%>"> <br> Width<br> <input name="globals[body_width]" type="text" id="globals[body_width]" value="<%=@globals.body_width%>"> <br></td> </tr> </table> </div> <div class="tabbertab"> <h2>Headings</h2> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td height="20" ><strong><font color="#000033">Edit Heading Styles </font></strong></td> </tr> </table> </div> <div class="tabbertab"> <h2>Links</h2> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td height="20" ><strong><font color="#000033">Edit Link Styles </font></strong></td> </tr> </table> <table width="100%" cellpadding="0" cellspacing="0" > <tr> <td width="50%" valign="top"><p><strong>Link/Active/Visited Styles </strong></p> Font BG Color <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="28%"><input name="globals[link_bg_color]" type="text" id="globals[link_bg_color]" value="<%=@globals.link_bg_color%>" size="14"></td> <td width="72%"><A HREF="#" onclick="pickerPopup202('globals[link_bg_color]','sample_id');"><img src="/images/colorpicker.gif" width="21" height="21" border="0"></A></td> </tr> </table> Font: <br> <input name="globals[link_font]" type="text" id="globals[link_font]" value="<%=@globals.link_font%>"> <br> Font Size: <br> <input name="globals[link_font_size]" type="text" id="globals[link_font_size]" value="<%=@globals.link_font_size%>"> <br> Font Color <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="28%"><input name="globals[link_font_color]" type="text" id="globals[link_font_color]" value="<%=@globals.link_font_color%>" size="14"></td> <td width="72%"><A HREF="#" onclick="pickerPopup202('globals[link_font_color]','sample_id');"><img src="/images/colorpicker.gif" width="21" height="21" border="0"></A></td> </tr> </table> Font Style <br> <select name="globals[link_font_style]"> <option value="" selected>Normal</option> <option value="bold">Bold</option> <option value="italic">Italic</option> </select> <br> Text Decoration <br> <select name="globals[link_text_decoration]" id="globals[link_text_decoration]"> <option value="none" selected>None</option> <option value="underline">Underline</option> </select> <br> </td> <td width="50%" valign="top"><p><strong>Hover Styles </strong></p> Font BG Color <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="26%"><input name="globals[hover_bg_color]" type="text" id="globals[hover_bg_color]" value="<%=@globals.hover_bg_color%>" size="14"></td> <td width="74%"><A HREF="#" onclick="pickerPopup202('globals[hover_bg_color]','sample_id');"><img src="/images/colorpicker.gif" width="21" height="21" border="0"></A></td> </tr> </table> Font <br> <input name="globals[hover_font]" type="text" id="globals[hover_font]" value="<%=@globals.hover_font%>"> <br> Font Size <br> <input name="globals[hover_font_size]" type="text" id="globals[hover_font_size]" value="@globals.hover_font_size"> <br> Font Color <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="26%"><input name="globals[hover_font_color]" type="text" id="globals[hover_font_color]" value="<%=@globals.hover_font_color%>" size="14"></td> <td width="74%"><A HREF="#" onclick="pickerPopup202('globals[hover_font_color]','sample_id');"><img src="/images/colorpicker.gif" width="21" height="21" border="0"></A></td> </tr> </table> Font Style <br> <select name="globals[hover_font_style]" id="globals[hover_font_style]"> <option value="" selected>Normal</option> <option value="bold">Bold</option> <option value="italic">Italic</option> </select> <br> Text Decoration <br> <select name="globals[hover_text_decoration]"> <option value="none" selected>None</option> <option value="underline">Underline</option> </select> <br> <p> </p></td> </tr> </table> </div> <div class="tabbertab"> <h2>Sides</h2> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td height="20" ><strong><font color="#000033">Edit Sidebar Styles </font></strong></td> </tr> </table> <table width="100%" cellpadding="0" cellspacing="0" > <tr> <td valign="top"><p><strong>Sidebar Styles (Left & Right)</strong></p> Left Side Width<br> <input name="globals[ltside_width]" type="text" id="globals[ltside_width]" value="<%=@globals.ltside_width%>"> <br> Right Side Width<br> <input name="globals[rtside_width]" type="text" id="globals[rtside_width]" value="<%=@globals.rtside_width%>"> <br> BG Color <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="28%"><input name="globals[side_bg_color]" type="text" id="globals[side_bg_color]" value="<%=@globals.side_bg_color%>" size="14"></td> <td width="72%"><A HREF="#" onclick="pickerPopup202('globals[side_bg_color]','sample_id');"><img src="/images/colorpicker.gif" width="21" height="21" border="0"></A></td> </tr> </table> BG Image <br> <input name="globals[side_bg_image]" type="text" id="globals[side_bg_image]" value="<%=@globals.side_bg_image%>"> <br> Border <br> <input name="globals[side_border]" type="text" id="globals[side_border]" value="<%=@globals.side_border%>"> <br> Border Color <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="28%"><input name="globals[side_border_color]" type="text" id="globals[side_border_color]" value="<%=@globals.side_border_color%>" size="14"></td> <td width="72%"><A HREF="#" onclick="pickerPopup202('globals[side_border_color]','sample_id');"><img src="/images/colorpicker.gif" width="21" height="21" border="0"></A></td> </tr> </table> Vertical Alignment<br> <select name="globals[side_valign]"> <option value="top" selected>Top</option> <option value="middle">Middle</option> <option value="bottom">Bottom</option> </select> <br> Font <br> <input name="globals[side_font]" type="text" id="globals[side_font]" value="<%=@globals.side_font%>"> <br> Font Size <br> <input name="globals[side_font_size]" type="text" id="globals[side_font_size]" value="<%=globals.side_font_size%>"> <br> Font Color <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="28%"><input name="globals[side_font_color]" type="text" id="globals[side_font_color]" value="<%=@globals.side_font_color%>" size="14"></td> <td width="72%"><A HREF="#" onclick="pickerPopup202('globals[side_font_color]','sample_id');"><img src="/images/colorpicker.gif" width="21" height="21" border="0"></A></td> </tr> </table> Font Style <br> <select name="globals[side_font_style]"> <option value="" selected>Normal</option> <option value="bold">Bold</option> <option value="italic">Italic</option> </select> <br> Text Decoration <br> <select name="globals[side_text_decoration]"> <option value="none" selected>None</option> <option value="underline">Underline</option> </select> <br> <p> </p></td> </tr> </table> </div> <div class="tabbertab"> <h2>Header/Footer</h2> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td height="20" ><strong><font color="#000033">Edit Header/Footer Styles </font></strong></td> </tr> </table> <table width="100%" cellpadding="0" cellspacing="0" > <tr> <td width="50%" valign="top"><p><strong>Header Styles </strong></p> BG Color <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="28%"><input name="globals[header_bg_color]" type="text" id="globals[header_bg_color]" value="<%=@globals.header_bg_color%>" size="14"></td> <td width="72%"><A HREF="#" onclick="pickerPopup202('globals[header_bg_color]','sample_id');"><img src="/images/colorpicker.gif" width="21" height="21" border="0"></A></td> </tr> </table> BG Image <br> <input name="globals[header_bg_image]" type="text" id="globals[header_bg_image]" value="<%=@globals.header_bg_image%>"> <br> Border <br> <input name="globals[header_border]" type="text" id="globals[header_border]" value="<%=@globals.header_border%>"> <br> Border Color <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="28%"><input name="globals[header_border_color]" type="text" id="globals[header_border_color]" value="<%=@globals.header_border_color%>" size="14"></td> <td width="72%"><A HREF="#" onclick="pickerPopup202('globals[header_border_color]','sample_id');"><img src="/images/colorpicker.gif" width="21" height="21" border="0"></A></td> </tr> </table> Vertical Alignment<br> <select name="globals[header_valign]"> <option value="top" selected>Top</option> <option value="middle">Middle</option> <option value="bottom">Bottom</option> </select> <br> Font <br> <input name="globals[header_font]" type="text" id="globals[header_font]" value="<%=@globals.header_font%>"> <br> Font Size <br> <input name="txtHDFONTSIZE" type="text" id="txtHDFONTSIZE" value="<%=objRS("CSS_HD_FONTSIZE")%>"> <br> Font Color <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="28%"><input name="globals[header_font_color]" type="text" id="globals[header_font_color]" value="<%=@globals.header_font_color%>" size="14"></td> <td width="72%"><A HREF="#" onclick="pickerPopup202('globals[header_font_color]','sample_id');"><img src="/images/colorpicker.gif" width="21" height="21" border="0"></A></td> </tr> </table> Font Style <br> <select name="globals[header_font_style]"> <option value="" selected>Normal</option> <option value="bold">Bold</option> <option value="italic">Italic</option> </select> <br> Text Decoration <br> <select name="globals[header_text_decoration]" > <option value="none" selected>None</option> <option value="underline">Underline</option> </select> <br> </td> <td width="50%" valign="top"><p><strong>Footer Styles </strong></p> BG Color <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="26%"><input name="globals[footer_bg_color]" type="text" id="globals[footer_bg_color]" value="<%=@globals.footer_bg_color%>" size="14"></td> <td width="74%"><A HREF="#" onclick="pickerPopup202('globals[footer_bg_color]','sample_id');"><img src="/images/colorpicker.gif" width="21" height="21" border="0"></A></td> </tr> </table> BG Image <br> <input name="globals[footer_bg_image]" type="text" id="globals[footer_bg_image]" value="<%=@globals.footer_bg_image%>"> <br> Border <br> <input name="globals[footer_border]" type="text" id="globals[footer_border]" value="<%=@globals.footer_border%>"> <br> Border Color <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="26%"><input name="globals[footer_border_color]" type="text" id="globals[footer_border_color]" value="<%=@globals.footer_border_color%>" size="14"></td> <td width="74%"><A HREF="#" onclick="pickerPopup202('globals[footer_border_color]','sample_id');"><img src="/images/colorpicker.gif" width="21" height="21" border="0"></A></td> </tr> </table> Vertical Alignment<br> <select name="globals[footer_valign]"> <option value="top" selected>Top</option> <option value="middle">Middle</option> <option value="bottom">Bottom</option> </select> <br> Font <br> <input name="globals[footer_font]" type="text" id="globals[footer_font]" value="<%=@globals.footer_font%>"> <br> Font Size <br> <input name="globals[footer_font_size]" type="text" id="globals[footer_font_size]" value="<%=@globals.footer_font_size%>"> <br> Font Color <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="26%"><input name="globals[footer_font_color]" type="text" id="globals[footer_font_color]" value="<%=@globals.footer_font_color%>" size="14"></td> <td width="74%"><A HREF="#" onclick="pickerPopup202('globals[footer_font_color]','sample_id');"><img src="/images/colorpicker.gif" width="21" height="21" border="0"></A></td> </tr> </table> Font Style <br> <select name="globals[footer_font_style]"> <option value="" selected>Normal</option> <option value="bold">Bold</option> <option value="italic">Italic</option> </select> <br> Text Decoration <br> <select name="globals[footer_text_decoration]"> <option value="none" selected>None</option> <option value="underline">Underline</option> </select> <br> <p> </p></td> </tr> </table> </div> <div class="tabbertab"> <h2>Main Content</h2> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td height="20" ><strong><font color="#000033">Edit Main Content Styles </font></strong></td> </tr> </table> <table width="100%" cellpadding="0" cellspacing="0" > <tr> <td valign="top"><p><strong>Main Content Area Styles </strong></p> Width<br> <input name="globals[main_width]" type="text" id="globals[main_width]" value="<%=@globals.main_width%>"> <br> BG Color <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="9%"><input name="globals[main_bg_color]" type="text" id="globals[main_bg_color]" value="<%=@globals.main_bg_color%>" size="14"></td> <td width="91%"><A HREF="#" onclick="pickerPopup202('globals[main_bg_color]','sample_id');"><img src="/images/colorpicker.gif" width="21" height="21" border="0"></A></td> </tr> </table> BG Image <br> <input name="globals[main_bg_image]" type="text" id="globals[main_bg_image]" value="<%=@globals.main_bg_image%>"> <br> Border <br> <input name="globals[main_border]" type="text" id="globals[main_border]" value="<%=@globals.main_border%>"> <br> Border Color <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="9%"><input name="globals[main_border_color]" type="text" id="globals[main_border_color]" value="<%=@globals.main_border_color%>" size="14"></td> <td width="91%"><A HREF="#" onclick="pickerPopup202('globals[main_border_color]','sample_id');"><img src="/images/colorpicker.gif" width="21" height="21" border="0"></A></td> </tr> </table> Vertical Alignment<br> <select name="globals[main_valign]"> <option value="top" selected>Top</option> <option value="middle">Middle</option> <option value="bottom">Bottom</option> </select> <br> Font Family <br> <input name="globals[main_font]" type="text" id="globals[main_border_font]" value="<%=@globals.main_font%>"> <br> Font Size <br> <input name="globals[main_font_size]" type="text" id="globals[main_font_size]" value="<%=@globals.main_font_size%>"> <br> Font Color <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="9%"><input name="globals[main_font_color]" type="text" id="globals[main_font_color]" value="<%=@globals.main_font_color%>" size="14"></td> <td width="91%"><A HREF="#" onclick="pickerPopup202('globals[main_font_color]','sample_id');"><img src="/images/colorpicker.gif" width="21" height="21" border="0"></A></td> </tr> </table> Font Style <br> <select name="globals[main_font_style]"> <option value="" selected>Normal</option> <option value="bold">Bold</option> <option value="italic">Italic</option> </select> <br> Text Decoration <br> <select name="globals[main_text_decoration]"> <option value="none" selected>None</option> <option value="underline">Underline</option> </select> </td> </tr> </table> </div> <p align="left"><%= submit_tag "Edit" %> <%= end_form_tag %> </form> </div> </td> </tr> </table> Here is my my controller code: def edit_globals @globals = Globals.find(:conditions => "id = 1") end def update_globals @globals = Globals.find(params[:id]) if @globals.update_attributes(params[:globals]) flash[:notice] = 'Global styles successfully updated.' redirect_to :action => 'list_product', :id => @products else render :action => 'edit_globals' end end Can anyone help me? I would really appreciate it. I am new to R & R and I am trying to migrate a classic asp app to this new language. |
||||||||||||
|
|
|||||||||||||
| RoR |
|
comprug
Forum Regular
|
Rob, I'm glad you decided to switch to RoR! I'm sure you'll enjoy it, and it's really paid off for me. To address your concerns, try this:
I replaced the id param with globals id because id is part of the globals hash. Hope this addresses your concerns. |
||||||||||||||
|
|
|||||||||||||||
|
pmeserve
HostMySite Tech
|
Yeah I'm having a bit of trouble reading the view...but it seems a little convoluted. First off I'd recommend using the form helper tags, picking the right variation for whether you're using 1.1.6 or 1.2.1.
But basically I'd have stuff like this: edit_globals should be renamed just edit - it should be in the globals controller and so specifying what you're editing is redundant. also if you're following Rails conventions, you shouldn't have a model named Globals, it should be singular Global:
the view:
update_globals should just be update, again following conventions and having it controller specific:
I'd really strongly recommend reading blogs like Rails Way. One of the biggest benefits of using Rails is adopting the conventions it encourages, which make possible most of the built in "magic", and keeps your code readable not just to yourself but to other Rails coders might wind up looking at it When I first started using Rails from PHP, I wrote code that looked a lot like my old PHP code. As time has gone on I've seen that I was very misguided in coding that way, and following the conventions and "rails idioms" has really benefited in making code clearer and more maintainable. This is going to be even more true going into the future if you want to start using REST It's nice that Rails allows you to ditch its conventions and just code the way you want, but you should only do this at times you absolutely need to |
||||||||||||||||||
|
|
|||||||||||||||||||
| Writing to Text Files (css) |
|
rdx73
|
Thank you. I have solved my own problem. I know that my coding style is rough right now, but it will improve as I gain experience.
Got another question though. The piece of code you just looked at writes style sheet values to a database for storage. But when they edit the values I'd like Ruby to also write to the css text file wolf.css in the public/stylesheets directory. Do you know of any good tutorials on how to write to text files using ruby on rails? |
||||||||||||
|
|
|||||||||||||
| Thanks comprug |
|
rdx73
|
Thanks for posting again to try and help me. Really appreciate it.
Originally, I had started coding it in ROR but became frustrated and turned to my old asp. Its kind of a CMS and kind of a Ecommerce cart, except it will use google buy buttons and eventually google's checkout api. It was almost finished in asp, but couldn't get the breadcrumbs and category editor to work. If you could spare a moment, could you point me to a good tutorial on how to write to text files (css) with Ruby? |
||||||||||||
|
|
|||||||||||||
| Editing Files |
|
comprug
Forum Regular
|
Rob,
here's the code you need in order to write to a file in Ruby:
I hope this addresses your concerns. By the way, I unfortunately won't be able to assist you further tonight because of the Bears and the Super Bowl, but if you have any further concerns, please post back. |
|||||||||||||
|
|
||||||||||||||
| Hi comprug |
|
rdx73
|
Can you expound on that last bit of advice. Specifically, I need to know how to write fields in a database one at a time to the text file. I am writing a style sheet for a page. For instance,this is how its done in asp:
Set objRS = GetData("SELECT * FROM tblGlobal") Do While Not objRS.EOF CSS_BODY_BG = objRS("CSS_BODY_BG") CSS_BODY_BGIMAGE = objRS("CSS_BODY_BGIMAGE") strCSS="BODY {" & VbCrLf &_ "background-color: " & CSS_BODY_BG & ";" & VbCrLf &_ "background-image: " & CSS_BODY_BGIMAGE & ";" & VbCrLf &_ "}" & VbCrLf CSS_LNK_BGCOLOR = objRS("CSS_LNK_BGCOLOR") CSS_LNK_FONT = objRS("CSS_LNK_FONT") CSS_LNK_FONTCOLOR = objRS("CSS_LNK_FONTCOLOR") CSS_LNK_FONTSIZE = objRS("CSS_LNK_FONTSIZE") CSS_LNK_FONTSTYLE = objRS("CSS_LNK_FONTSTYLE") CSS_LNK_TXTDEC = objRS("CSS_LNK_TXTDEC") strCSS= strCSS + "a:link,a:visited,a:active{" & VbCrLf &_ "background-color: " & CSS_LNK_BGCOLOR & ";" & VbCrLf &_ "font-family: " & CSS_LNK_FONT & ";" & VbCrLf &_ "font-size: " & CSS_LNK_FONTSIZE & ";" & VbCrLf &_ "font-style: " & CSS_LNK_FONTSTYLE & ";" & VbCrLf &_ "text-decoration: " & CSS_LNK_TXTDEC & ";" & VbCrLf &_ "color: " & CSS_LNK_FONTCOLOR & ";" & VbCrLf &_ "}" & VbCrLf CSS_HVR_BGCOLOR = objRS("CSS_HVR_BGCOLOR") CSS_HVR_FONT = objRS("CSS_HVR_FONT") CSS_HVR_FONTCOLOR = objRS("CSS_HVR_FONTCOLOR") CSS_HVR_FONTSIZE = objRS("CSS_HVR_FONTSIZE") CSS_HVR_FONTSTYLE = objRS("CSS_HVR_FONTSTYLE") CSS_HVR_TXTDEC = objRS("CSS_HVR_TXTDEC") strCSS= strCSS + "a:hover{" & VbCrLf &_ "background-color: " & CSS_HVR_BGCOLOR & ";" & VbCrLf &_ "font-family: " & CSS_HVR_FONT & ";" & VbCrLf &_ "font-size: " & CSS_HVR_FONTSIZE & ";" & VbCrLf &_ "font-style: " & CSS_HVR_FONTSTYLE & ";" & VbCrLf &_ "text-decoration: " & CSS_HVR_TXTDEC & ";" & VbCrLf &_ "color: " & CSS_HVR_FONTCOLOR & ";" & VbCrLf &_ "}" & VbCrLf CSS_H1_BGCOLOR = objRS("CSS_H1_BGCOLOR") CSS_H1_FONT = objRS("CSS_H1_FONT") CSS_H1_FONTSIZE = objRS("CSS_H1_FONTSIZE") CSS_H1_FONTSTYLE = objRS("CSS_H1_FONTSTYLE") CSS_H1_FONTCOLOR = objRS("CSS_H1_FONTCOLOR") CSS_H1_TXTDEC = objRS("CSS_H1_TXTDEC") strCSS= strCSS + "h1{" & VbCrLf &_ "background-color: " & CSS_H1_BGCOLOR & ";" & VbCrLf &_ "font-family: " & CSS_H1_FONT & ";" & VbCrLf &_ "font-size: " & CSS_H1_FONTSIZE & ";" & VbCrLf &_ "font-style: " & CSS_H1_FONTSTYLE & ";" & VbCrLf &_ "text-decoration: " & CSS_H1_TXTDEC & ";" & VbCrLf &_ "color: " & CSS_H1_FONTCOLOR & ";" & VbCrLf &_ "}" & VbCrLf CSS_H2_BGCOLOR = objRS("CSS_H2_BGCOLOR") CSS_H2_FONT = objRS("CSS_H2_FONT") CSS_H2_FONTSIZE = objRS("CSS_H2_FONTSIZE") CSS_H2_FONTSTYLE = objRS("CSS_H2_FONTSTYLE") CSS_H2_FONTCOLOR = objRS("CSS_H2_FONTCOLOR") CSS_H2_TXTDEC = objRS("CSS_H2_TXTDEC") strCSS= strCSS + "h2{" & VbCrLf &_ "background-color: " & CSS_H2_BG & ";" & VbCrLf &_ "font-family: " & CSS_H2_FONT & ";" & VbCrLf &_ "font-size: " & CSS_H2_FONTSIZE & ";" & VbCrLf &_ "font-style: " & CSS_H2_FONTSTYLE & ";" & VbCrLf &_ "text-decoration: " & CSS_H2_TXTDEC & ";" & VbCrLf &_ "color: " & CSS_H2_FONTCOLOR & ";" & VbCrLf &_ "}" & VbCrLf CSS_H3_BGCOLOR = objRS("CSS_H3_BGCOLOR") CSS_H3_FONT = objRS("CSS_H3_FONT") CSS_H3_FONTSIZE = objRS("CSS_H3_FONTSIZE") CSS_H3_FONTSTYLE = objRS("CSS_H3_FONTSTYLE") CSS_H3_FONTCOLOR = objRS("CSS_H3_FONTCOLOR") CSS_H3_TXTDEC = objRS("CSS_H3_TXTDEC") strCSS= strCSS + "h3{" & VbCrLf &_ "background-color: " & CSS_H3_BG & ";" & VbCrLf &_ "font-family: " & CSS_H3_FONT & ";" & VbCrLf &_ "font-size: " & CSS_H3_FONTSIZE & ";" & VbCrLf &_ "font-style: " & CSS_H3_FONTSTYLE & ";" & VbCrLf &_ "text-decoration: " & CSS_H3_TXTDEC & ";" & VbCrLf &_ "color: " & CSS_H3_FONTCOLOR & ";" & VbCrLf &_ "}" & VbCrLf CSS_LTSIDE_BGIMAGE = objRS("CSS_LTSIDE_BGIMAGE") CSS_LTSIDE_BGCOLOR = objRS("CSS_LTSIDE_BGCOLOR") CSS_LTSIDE_BORDER = objRS("CSS_LTSIDE_BORDER") CSS_LTSIDE_BORDERCOLOR = objRS("CSS_LTSIDE_BORDERCOLOR") CSS_LTSIDE_VALIGN = objRS("CSS_LTSIDE_VALIGN") CSS_LTSIDE_FONT = objRS("CSS_LTSIDE_FONT") CSS_LTSIDE_FONTSIZE = objRS("CSS_LTSIDE_FONTSIZE") CSS_LTSIDE_FONTSTYLE = objRS("CSS_LTSIDE_FONTSTYLE") CSS_LTSIDE_FONTCOLOR = objRS("CSS_LTSIDE_FONTCOLOR") CSS_LTSIDE_TXTDEC = objRS("CSS_LTSIDE_TXTDEC") strCSS= strCSS + "#CSS_LTSIDE{" & VbCrLf &_ "background-color: " & CSS_LTSIDE_BGCOLOR & ";" & VbCrLf &_ "background-image: " & CSS_LTSIDE_BGIMAGE & ";" & VbCrLf &_ "border: " & CSS_LTSIDE_BORDER & ";" & VbCrLf &_ "border-color: " & CSS_LTSIDE_BORDERCOLOR & ";" & VbCrLf &_ "vertical-align: " & CSS_LTSIDE_VALIGN & ";" & VbCrLf &_ "font-family: " & CSS_LTSIDE_FONT & ";" & VbCrLf &_ "font-size: " & CSS_LTSIDE_FONTSIZE & ";" & VbCrLf &_ "font-style: " & CSS_LTSIDE_FONTSTYLE & ";" & VbCrLf &_ "text-decoration: " & CSS_LTSIDE_TXTDEC & ";" & VbCrLf &_ "color: " & CSS_LTSIDE_FONTCOLOR & ";" & VbCrLf &_ "}" & VbCrLf CSS_RTSIDE_BGIMAGE = objRS("CSS_RTSIDE_BGIMAGE") CSS_RTSIDE_BGCOLOR = objRS("CSS_RTSIDE_BGCOLOR") CSS_RTSIDE_BORDER = objRS("CSS_RTSIDE_BORDER") CSS_RTSIDE_BORDERCOLOR = objRS("CSS_RTSIDE_BORDERCOLOR") CSS_RTSIDE_VALIGN = objRS("CSS_RTSIDE_VALIGN") CSS_RTSIDE_FONT = objRS("CSS_RTSIDE_FONT") CSS_RTSIDE_FONTSIZE = objRS("CSS_RTSIDE_FONTSIZE") CSS_RTSIDE_FONTSTYLE = objRS("CSS_RTSIDE_FONTSTYLE") CSS_RTSIDE_TXTDEC = objRS("CSS_RTSIDE_TXTDEC") CSS_RTSIDE_FONTCOLOR = objRS("CSS_RTSIDE_FONTCOLOR") strCSS= strCSS + "#CSS_RTSIDE{" & VbCrLf &_ "background-color: " & CSS_RTSIDE_BGCOLOR & ";" & VbCrLf &_ "background-image: " & CSS_RTSIDE_BGIMAGE & ";" & VbCrLf &_ "border: " & CSS_RTSIDE_BORDER & ";" & VbCrLf &_ "border-color: " & CSS_RTSIDE_BORDERCOLOR & ";" & VbCrLf &_ "vertical-align: " & CSS_RTSIDE_VALIGN & ";" & VbCrLf &_ "font-family: " & CSS_RTSIDE_FONT & ";" & VbCrLf &_ "font-size: " & CSS_RTSIDE_FONTSIZE & ";" & VbCrLf &_ "font-style: " & CSS_RTSIDE_FONTSTYLE & ";" & VbCrLf &_ "text-decoration: " & CSS_RTSIDE_TXTDEC & ";" & VbCrLf &_ "color: " & CSS_RTSIDE_FONTCOLOR & ";" & VbCrLf &_ "}" & VbCrLf CSS_HD_BGIMAGE = objRS("CSS_HD_BGIMAGE") CSS_HD_BGCOLOR = objRS("CSS_HD_BGCOLOR") CSS_HD_BORDER = objRS("CSS_HD_BORDER") CSS_HD_BORDERCOLOR = objRS("CSS_HD_BORDERCOLOR") CSS_HD_VALIGN = objRS("CSS_HD_VALIGN") CSS_HD_FONT = objRS("CSS_HD_FONT") CSS_HD_FONTSIZE = objRS("CSS_HD_FONTSIZE") CSS_HD_FONTSTYLE = objRS("CSS_HD_FONTSTYLE") CSS_HD_TXTDEC = objRS("CSS_HD_TXTDEC") CSS_HD_FONTCOLOR = objRS("CSS_HD_FONTCOLOR") strCSS= strCSS + "#CSS_HEADER{" & VbCrLf &_ "background-color: " & CSS_HD_BGCOLOR & ";" & VbCrLf &_ "background-image: " & CSS_HD_BGIMAGE & ";" & VbCrLf &_ "border: " & CSS_HD_BORDER & ";" & VbCrLf &_ "border-color: " & CSS_HD_BORDERCOLOR & ";" & VbCrLf &_ "vertical-align: " & CSS_HD_VALIGN & ";" & VbCrLf &_ "font-family: " & CSS_HD_FONT & ";" & VbCrLf &_ "font-size: " & CSS_HD_FONTSIZE & ";" & VbCrLf &_ "font-style: " & CSS_HD_FONTSTYLE & ";" & VbCrLf &_ "text-decoration: " & CSS_HD_TXTDEC & ";" & VbCrLf &_ "color: " & CSS_HD_FONTCOLOR & ";" & VbCrLf &_ "}" & VbCrLf CSS_FOOTER_BGIMAGE = objRS("CSS_FOOTER_BGIMAGE") CSS_FOOTER_BGCOLOR = objRS("CSS_FOOTER_BGCOLOR") CSS_FOOTER_BORDER = objRS("CSS_FOOTER_BORDER") CSS_FOOTER_BORDERCOLOR = objRS("CSS_FOOTER_BORDERCOLOR") CSS_FOOTER_VALIGN = objRS("CSS_FOOTER_VALIGN") CSS_FOOTER_FONT = objRS("CSS_FOOTER_FONT") CSS_FOOTER_FONTSIZE = objRS("CSS_FOOTER_FONTSIZE") CSS_FOOTER_FONTSTYLE = objRS("CSS_FOOTER_FONTSTYLE") CSS_FOOTER_TXTDEC = objRS("CSS_FOOTER_TXTDEC") CSS_FOOTER_FONTCOLOR = objRS("CSS_FOOTER_FONTCOLOR") strCSS= strCSS + "#CSS_FOOTER{" & VbCrLf &_ "background-color: " & CSS_FOOTER_BGCOLOR & ";" & VbCrLf &_ "background-image: " & CSS_FOOTER_BGIMAGE & ";" & VbCrLf &_ "border: " & CSS_FOOTER_BORDER & ";" & VbCrLf &_ "border-color: " & CSS_FOOTER_BORDERCOLOR & ";" & VbCrLf &_ "vertical-align: " & CSS_FOOTER_VALIGN & ";" & VbCrLf &_ "font-family: " & CSS_FOOTER_FONT & ";" & VbCrLf &_ "font-size: " & CSS_FOOTER_FONTSIZE & ";" & VbCrLf &_ "font-style: " & CSS_FOOTER_FONTSTYLE & ";" & VbCrLf &_ "text-decoration: " & CSS_FOOTER_TXTDEC & ";" & VbCrLf &_ "color: " & CSS_FOOTER_FONTCOLOR & ";" & VbCrLf &_ "}" & VbCrLf CSS_MAIN_BGIMAGE = objRS("CSS_MAIN_BGIMAGE") CSS_MAIN_BGCOLOR = objRS("CSS_MAIN_BGCOLOR") CSS_MAIN_BORDER = objRS("CSS_MAIN_BORDER") CSS_MAIN_BORDERCOLOR = objRS("CSS_MAIN_BORDERCOLOR") CSS_MAIN_VALIGN = objRS("CSS_MAIN_VALIGN") CSS_MAIN_FONT = objRS("CSS_MAIN_FONT") CSS_MAIN_FONTSIZE = objRS("CSS_MAIN_FONTSIZE") CSS_MAIN_FONTSTYLE = objRS("CSS_MAIN_FONTSTYLE") CSS_MAIN_TXTDEC = objRS("CSS_MAIN_TXTDEC") CSS_MAIN_FONTCOLOR = objRS("CSS_MAIN_FONTCOLOR") strCSS= strCSS + "#CSS_MAIN{" & VbCrLf &_ "background-color: " & CSS_MAIN_BGCOLOR & ";" & VbCrLf &_ "background-image: " & CSS_MAIN_BGIMAGE & ";" & VbCrLf &_ "border: " & CSS_MAIN_BORDER & ";" & VbCrLf &_ "border-color: " & CSS_MAIN_BORDERCOLOR & ";" & VbCrLf &_ "vertical-align: " & CSS_MAIN_VALIGN & ";" & VbCrLf &_ "font-family: " & CSS_MAIN_FONT & ";" & VbCrLf &_ "font-size: " & CSS_MAIN_FONTSIZE & ";" & VbCrLf &_ "font-style: " & CSS_MAIN_FONTSTYLE & ";" & VbCrLf &_ "text-decoration: " & CSS_MAIN_TXTDEC & ";" & VbCrLf &_ "color: " & CSS_MAIN_FONTCOLOR & ";" & VbCrLf &_ "}" & VbCrLf objRS.MoveNext Loop objRS.Close 'this line creates an instance of the File Scripting Object named myFSO Set myFSO = CreateObject("Scripting.FileSystemObject") 'this line opens the file, notice the 2, it will cause the script to write to the file (overwriting existing text) Set WriteStuff = myFSO.OpenTextFile("c:\Websites\hp31d8fa\chosonWCv1.0\css\wolf.css", 2, True) 'this line actually writes STUFF from above to the file WriteStuff.WriteLine(strCSS) ''this line closes the file WriteStuff.Close 'this line destroys the instance of the File Scripting Object named WriteStuff SET WriteStuff = NOTHING 'this line destroys the instance of the File Scripting Object named myFSO SET myFSO = NOTHING CloseDB() 'response.write strCSS Response.Redirect "index.asp?Action=globalset" Thanks for taking a look. Appreciate any help I can get. |
||||||||||||
|
|
|||||||||||||
| Let me clarify |
|
comprug
Forum Regular
|
Sorry, but I'm ASP illiterate. If possible could you clarify how your database structure works? do you have a column in the table for each css attribute, or do you have a column for the property and the value?
|
||||||||||||
|
|
|||||||||||||
| Hi |
|
rdx73
|
Here is a dump of that table where each value is the value of that css attribute:
CREATE TABLE /*!32312 IF NOT EXISTS*/ `globals` ( `id` int(10) NOT NULL auto_increment, `meta_title` varchar(255) default NULL, `meta_description` varchar(255) default NULL, `meta_keywords` longtext, `meta_classification` varchar(255) default NULL, `meta_author` varchar(255) default NULL, `meta_copyright` varchar(255) default NULL, `js_includes` longtext, `bodytag` longtext, `header_html` longtext, `footer_html` longtext, `body_width` varchar(255) default NULL, `main_width` varchar(255) default NULL, `rtside_width` varchar(255) default NULL, `ltside_width` varchar(255) default NULL, `body_bg_color` varchar(255) default NULL, `body_bg_image` varchar(255) default NULL, `link_bg_color` varchar(255) default NULL, `link_font` varchar(255) default NULL, `link_font_size` varchar(255) default NULL, `link_font_color` varchar(255) default NULL, `link_font_style` varchar(255) default NULL, `link_text_decoration` varchar(255) default NULL, `hover_bg_color` varchar(255) default NULL, `hover_font` varchar(255) default NULL, `hover_font_size` varchar(255) default NULL, `hover_font_color` varchar(255) default NULL, `hover_font_style` varchar(255) default NULL, `hover_text_decoration` varchar(255) default NULL, `side_bg_color` varchar(255) default NULL, `side_bg_image` varchar(255) default NULL, `side_border` varchar(255) default NULL, `side_border_color` varchar(255) default NULL, `side_valign` varchar(255) default NULL, `side_font_color` varchar(255) default NULL, `side_font` varchar(255) default NULL, `side_font_size` varchar(255) default NULL, `side_font_style` varchar(255) default NULL, `side_text_decoration` varchar(255) default NULL, `main_bg_color` varchar(255) default NULL, `main_bg_image` varchar(255) default NULL, `main_border` varchar(255) default NULL, `main_border_color` varchar(255) default NULL, `main_valign` varchar(255) default NULL, `main_font_color` varchar(255) default NULL, `main_font` varchar(255) default NULL, `main_font_size` varchar(255) default NULL, `main_font_style` varchar(255) default NULL, `main_text_decoration` varchar(255) default NULL, `footer_bg_color` varchar(255) default NULL, `footer_bg_image` varchar(255) default NULL, `footer_border` varchar(255) default NULL, `footer_border_color` varchar(255) default NULL, `footer_font_color` varchar(255) default NULL, `footer_valign` varchar(255) default NULL, `footer_font` varchar(255) default NULL, `footer_font_size` varchar(255) default NULL, `footer_font_style` varchar(255) default NULL, `footer_text_decoration` varchar(255) default NULL, `header_bg_image` varchar(255) default NULL, `header_bg_color` varchar(255) default NULL, `header_bg_border` varchar(255) default NULL, `header_border_color` varchar(50) default NULL, `header_valign` varchar(255) default NULL, `header_font` varchar(255) default NULL, `header_font_color` varchar(50) default NULL, `header_font_size` varchar(255) default NULL, `header_font_style` varchar(255) default NULL, `header_text_decoration` varchar(255) default NULL, `lt_search_form` varchar(255) default NULL, `lt_manufacturer_menu` varchar(255) default NULL, `lt_category_menu` varchar(255) default NULL, `lt_custom_top` longtext, `lt_custom_bottom` longtext, `rt_search_form` varchar(255) default NULL, `rt_manufacturer_menu` varchar(255) default NULL, `rt_category_menu` varchar(255) default NULL, `rt_custom_top` longtext, `rt_custom_bottom` longtext, `custom_navigation` varchar(255) default NULL, PRIMARY KEY (`id`), KEY `ID` (`id`) |
||||||||||||
|
|
|||||||||||||
| Writing to a css file |
|
comprug
Forum Regular
|
Rob, here's how you do this:
|
|||||||||||||||
|
|
||||||||||||||||
| Thank You! |
|
rdx73
|
Thanks for helping me with that. Appreciate it a lot.
|
||||||||||||
|
|
|||||||||||||
| Sorry...little confused... |
|
rdx73
|
Here is what the finished style sheet would resemble after writing to it:
BODY { background-color: #000033; background-image: ; } a:link,a:visited,a:active{ background-color: ; font-family: Tahoma; font-size: 12px; font-style: ; text-decoration: none; color: #000099; } a:hover{ background-color: ; font-family: Tahoma; font-size: 12px; font-style: ; text-decoration: underline; color: #000033; } h1{ background-color: #990000; font-family: Tahoma; font-size: 16px; font-style: ; text-decoration: none; color: ; } h2{ background-color: ; font-family: Tahoma; font-size: 14px; font-style: ; text-decoration: none; color: ; } h3{ background-color: ; font-family: Tahoma; font-size: 12px; font-style: ; text-decoration: none; color: ; } #CSS_LTSIDE{ background-color: #EEEEEE; background-image: ; border: ; border-color: #EEEEEE; vertical-align: top; font-family: Tahoma; font-size: 12px; font-style: ; text-decoration: none; color: ; } #CSS_RTSIDE{ background-color: #EEEEEE; background-image: ; border: ; border-color: ; vertical-align: top; font-family: Tahoma; font-size: 12px; font-style: ; text-decoration: none; color: ; } #CSS_HEADER{ background-color: #666666; background-image: ; border: ; border-color: ; vertical-align: top; font-family: Tahoma; font-size: 12px; font-style: ; text-decoration: none; color: ; } #CSS_FOOTER{ background-color: #990000; background-image: ; border: ; border-color: ; vertical-align: top; font-family: Tahoma; font-size: 12px; font-style: ; text-decoration: none; color: #ffffff; } #CSS_MAIN{ background-color: #ffffff; background-image: ; border: ; border-color: #ffffff; vertical-align: top; font-family: Tahoma; font-size: 12px; font-style: ; text-decoration: none; color: ; } In the following excerpt of the code you gave me: globals = Global.find(# id of your page in the db) txt=" #side { BACKGROUND-COLOR: #{globals.side_bg_color}; is the pound and bracket after 'BACKGROUND-COLOR:' part of ROR syntax or is that a beginning bracket for the style sheet? Here is some code I tried that I put in my admin controller, but it is not writing to the stylesheet or throwing any errors: def update_globals @globals = Global.find(params[:id]) if @globals.update_attributes(params[:globals]) flash[:notice] = 'Global styles successfully updated.' @globals = Global.find(params[:id]) txt="BODY {background-color: Global.body_bg_color; background-image: Global.body_bg_image;}" # assign the value of the css file to the txt variable File.open("\depot\public\stylesheets\wolf.css", "a") { |t| t.puts txt } render :action => 'edit_globals', :id => @globals else render :action => 'edit_globals' end end |
||||||||||||
|
|
|||||||||||||
| Ruby Brackets |
|
comprug
Forum Regular
|
Rob, the brackets are part of Ruby code. In quotations, values are dynamically inserted by using #{}. This should address your concerns.
|
||||||||||||
|
|
|||||||||||||
| Bad Path to CSS File |
|
rdx73
|
I am running this on localhost:3000. Is this the right path:
/depot/public/stylesheets/wolf.css or is it /public/stylesheets/wolf.css Nothing seems to work. |
||||||||||||
|
|
|||||||||||||
| Complete Path |
|
rdx73
|
C:\ruby\rails_apps\depot\public\stylesheets\wolf.css
|
||||||||||||
|
|
|||||||||||||
| Help Editing Record |
|
||
|


