beginner s question

Hello, I think I have logical problem about rails. I want to integrate my plugin to my rails project. the plugin is kind of converter.the plugin takes datas from database and convert into xml file.

I have a selection_tag that gets parameter from the user and passes it to a controller.I want to access that data within the controller. Converter needs parameter from the selection which is including the name of the templates.

@templates_array = get_templates "#{get_plugin_root}/public/converter/templates/" converter_generate(sheet_id,date, output_path, template_path) template_path = "#{get_plugin_root}/public/converter/templates/#{params[:template]}.xml"

my selection is like ; <%           templateOptions = ""             @templates_array.each do |i|                 templateOptions = templateOptions + "<option value=#{i}>#{i}</option>"             end             %>

          <%=select_tag "template", templateOptions%>

the array takes name of the templates from folder and add them to selection_tag. my first question is how will I get the parameter from user. I can not get it. and second one is how will I add new option and value to this selection.when I add option it creates the length of the array. I just want to add single one. by the way this is not used in form, it s not the object of form.

Hello,

................... QUESTION 1 ...................

my first question is how will I get the parameter from user. I can not get it. ...bla..bla by the way this is not used in form, it s not the object of form.

if it is not form, how selected template from user will be sent to your controller? maybe you should add your own form_tag to execute that select_tag. Or maybe it use JS or RJS or AJAX that has function as form_tag or maybe it is sent to cookies or session, please check again. Honestly, I never use this plug-in but i understand your problem is.

................... QUESTION 2 ...................

and second one is how will I add new option and value to this selection.when I add option it creates the length of the array. I just want to add single one.

Have you tried this?

<%    templateOptions = ""    @templates_array.each do |i|

   templateOptions = templateOptions +                     "<option value=#{i}>#{i}</option>" +                     "<option value=#{your_value}>#{your_description}</option>"

   end %>

OR

<%    templateOptions = ""    @templates_array.each do |i|

   templateOptions = templateOptions +                     "<option value=#{i}>#{i}</option>" +                       options_for_select([ "1", "2", "3", "4"], "1")    end %>

I hope it can answer your doubtful. Good Luck.

<%- content_for :head do -%> <%= stylesheet_link_tag 'prototype-ui' %> <%= stylesheet_link_tag 'actions/project_sheet' %> <%= javascript_include_tag 'vendor/prototype-ui/window' %> <%= javascript_include_tag 'vendor/jquery' %> <script type="text/javascript">jQuery.noConflict()</script> <!--[if IE]><%= javascript_include_tag 'vendor/excanvas' %><![endif]--> <%= javascript_include_tag 'vendor/jquery.flot.js' %> <%= javascript_include_tag 'prototype-ui', :charset => 'UTF-8' %> <%= javascript_include_tag 'project_lock', :charset => 'UTF-8' %> <%= javascript_include_tag :project_sheet, :charset => 'UTF-8' %> <script type="text/javascript"> document.observe('dom:loaded', function() {   Sheet.run({   <%-# resources -%>     custom_count_ids: <%= @custom_counts.map(&:id).to_json %>,     custom_counts: <%= @custom_counts_hash.to_json(:for => :sheet) %>,     location_ids: <%= @locations.map(&:id).to_json %>,     locations: <%= @locations_hash.to_json(:for => :sheet) %>,     role_ids: <%= @roles.map(&:id).to_json %>,     roles: <%= @roles_hash.to_json(:for => :sheet) %>,     skill_ids: <%= @skills.map(&:id).to_json %>,     skills: <%= @skills_hash.to_json(:for => :sheet) %>,     shift_ids: <%= @shifts.map(&:id).to_json %>,     shifts: <%= @shifts_hash.to_json(:for => :sheet) %>,     shift_label_ids: <%= @shift_labels.map(&:id).to_json %>,     shift_labels: <%= @shift_labels_hash.to_json(:for => :sheet) %>,     staff_ids: <%= @staffs.map(&:id).to_json %>,     staffs: <%= @staffs_hash.to_json(:for => :sheet) %>,     task_ids: <%= @tasks.map(&:id).to_json %>,     tasks: <%= @tasks_hash.to_json(:for => :sheet) %>,   <%-# work -%>     cells: <%= @t_project_work_sheet_cells_json %>,     supply_work_sheets: <%= @supply_work_sheets.to_json(:for => :sheet) %>,     last_project: {       shifts: <%= @last_project_shifts_hash.to_json(:for => :sheet) %>,       cells: <%= @last_project_work_sheet_cells_json %>     },   <%-# calendar -%>     date_indexes_events: <%= XProjectDateIndexXEvent.json(current_project) %>,     date_indexes_tasks: <%= XProjectDateIndexXTask.json(current_project) %>,     date_indexes_memos: <%= XProjectDateIndexXMemo.json(current_project) %>,   <%-# staff -%>     assignable_shift_ids: <%= @assignable_shifts.map(&:id).to_json %>,     staffs_skills: <%= @staffs_skills.to_json %>,     staffs_shifts: <%= @staffs_shifts.to_json %>,   <%-# demand -%>     demand: <%= TProjectDemand.demand(current_project).to_json %>,     demand_month_labels: <%= @demand_month_labels.to_json %>,     demand_day_labels: <%= @demand_day_labels.to_json %>,   <%-# common -%>     lock: {       access_code: <%= @access_code.to_json %>,       status: <%= @lock_status.to_json(:for => :sheet) %>     },     project: {       published: <%= current_project.published.to_json %>,       max_task_per_day: <%= current_project.max_task_per_day.to_json %>     },     url: {       lock: '<%= url_for :action => 'lock' %>',       unlock: '<%= url_for :action => 'unlock' %>',       save: '<%= url_for :action => 'save' %>',       publish: '<%= url_for :action => 'publish' %>',       unpublish: '<%= url_for :action => 'unpublish' %>',       save_preset: '<%= url_for :action => 'save_preset' %>',       load_preset: '<%= url_for :action => 'load_preset' %>',       save_supply: '<%= url_for :action => 'save_supply' %>',       load_supply: '<%= url_for :action => 'load_supply' %>',       generate_demand: '<%= url_for :action => 'generate_demand' %>',       work_sheet_print: '<%= url_for :controller => '/project/report', :action => 'work_sheet_print' %>',       work_sheet_csv: '<%= url_for :controller => '/project/report', :action => 'work_sheet_csv' %>',       demand_csv: '<%= url_for :controller => '/project/report', :action => 'demand_csv' %>',       shift_report: '<%= url_for :controller => '/project/report', :action => 'shift_report' %>',       evaluate: '<%= url_for :controller => '/project/report', :action => 'evaluate' %>',

      config: '<%= t_project_config_path %>',       custom_counts: '<%= t_project_custom_counts_path %>',       locations: '<%= t_project_locations_path %>',       roles: '<%= t_project_roles_path %>',       role_shift: '<%= t_project_role_shift_path %>',       shifts: '<%= t_project_shifts_path %>',       shift_config: '<%= t_project_shift_config_path %>',       shift_labels: '<%= t_project_shift_labels_path %>',       skills: '<%= t_project_skills_path %>',       staffs: '<%= t_project_staffs_path %>',       tasks: '<%= t_project_tasks_path %>',

      resource: {         custom_count: '<%= t_project_custom_counts_path %>.json',         location: '<%= t_project_locations_path %>.json',         role: '<%= t_project_roles_path %>.json',         shift: '<%= t_project_shifts_path %>.json',         shift_config: '<%= t_project_shifts_path %>.json',         shift_label: '<%= t_project_shift_labels_path %>.json',         skill: '<%= t_project_skills_path %>.json',         staff: '<%= t_project_staffs_path %>.json',         task: '<%= t_project_tasks_path %>.json'       },

      observe: {         custom_count: /^<%= t_project_custom_counts_path .gsub('/', '\/') %>(?:\/(\d+))?$/,         location: /^<%= t_project_locations_path .gsub('/', '\/') %>(?:\/(\d+))?$/,         role: /^<%= t_project_roles_path .gsub('/', '\/') %>(?:\/(\d+))?$/,         shift: /^<%= t_project_shifts_path .gsub('/', '\/') %>(?:\/(\d+))?$/,         shift_config: /^<%= t_project_shift_config_path .gsub('/', '\/') %>$/,         shift_label: /^<%= t_project_shift_labels_path .gsub('/', '\/') %>(?:\/(\d+))?$/,         skill: /^<%= t_project_skills_path .gsub('/', '\/') %>(?:\/(\d+))?$/,         staff: /^<%= t_project_staffs_path .gsub('/', '\/') %>(?:\/(\d+))?$/,         task: /^<%= t_project_tasks_path .gsub('/', '\/') %>(?:\/(\d+))?$/       }     }   }); }); </script> <%- end -%>

<div style="margin:5px 10px 0;float:right">   <span id="lock_status"></span>   &nbsp;&nbsp;&nbsp;&nbsp;   <select id="global_menu">     <option value=""><%=h _('-- 設定メニュー --') %></option>     <option value="staffs" ><%=h _('Staff') %></option>     <option value="shifts" ><%=h _('Shift') %></option>     <option value="shift_config" ><%=h WO::Util.tree_child + _('高度な設定') %></option>     <option value="shift_labels" ><%=h WO::Util.tree_child + (_('%sの作成') % _('Label')) %></option>     <option value="role_shift" ><%=h WO::Util.tree_last_child + _('業務バインド') %></option>     <option value="locations" ><%=h _('Location') %></option>     <option value="roles" ><%=h _('Role') %></option>     <option value="skills" ><%=h _('Skill') %></option>     <option value="tasks" ><%=h _('Task') %></option>     <option value="custom_counts"><%=h _('t project custom count') %></option>     <option value="config" ><%=h _('t project config') %></option>     <option value="save_preset" ><%=h _('%sへの反映') % _('Preset') %></option>     <option value="load_preset" ><%=h _('%sのロード') % _('Preset') %></option>   </select> </div>

<div style="margin:0 10px">   <table class="usual">     <tr>       <th><%=h _('対象サイト') %></th>       <td><%=h current_project.site.name %></td>       <th><%=h _('TProject|Name') %></th>       <td><%=h current_project.name %></td>     </tr>   </table> </div>

<div id="tab" class="tab">   <ul>     <%= print_tab _('t project work sheet'), nil, false, :id => 'tab_work_sheet' %>     <%= print_tab _('Calendar'), nil, false, :id => 'tab_calendar_sheet' %>     <%= print_tab _('Staff'), nil, false, :id => 'tab_staff_sheet' %>     <%= print_tab _('Demand'), nil, false, :id => 'tab_demand_sheet' %>   </ul>   <ul class="right">     <%= print_tab _('Optimize') + ' >>', { :controller => '/project/optimize', :ac => @access_code }, false, :id => 'tab_optimize' %>   </ul> </div>

<div id="sheet_container"> <%= render :partial => 'work_sheet' %> <%= render :partial => 'calendar_sheet' %> <%= render :partial => 'staff_sheet' %> <%= render :partial => 'demand_sheet' %> </div>

<div id="global_buttons" class="buttons" style="margin:5px 10px 0">   <div style="float:left">     <input id="save" type="button" value="<%=h _('Save') %>" disabled="disabled" />     <input id="publish" type="button" value="<%=h _('Publish') %>" disabled="disabled" />     <input id="unpublish" class="long" type="button" value="<%=h _('%sの解除') % _('Publish') %>" style="display:none" />     <input id="work_sheet_print" class="long" type="button" value="<%=h _('シフト表印刷') %>" />     <input id="work_sheet_csv" class="long" type="button" value="<%=h _('シフト表CSV出力') %>" />     <%- if current_account.system? || current_account.enterprise? -%>     <input id="demand_csv" class="long" type="button" value="<%=h _('デマンドCSV出力') %>" />     <%- end -%>     <input id="shift_report" class="long" type="button" value="<%=h _('集計レポート') %>" />     <input id="evaluate" type="button" value="<%=h _('評価') %>" />   </div>

  <div style="text-align:right">     <input id="close" type="button" value="<%=h _('Close') %>" />   </div> </div>

this is my view page. I tried to add new div and form in it but this time it gives router error. resources = {    :custom_count => { :collection => { :sort => :get, :update_sort => :put } },    :location => { :collection => { :sort => :get, :update_sort => :put } },    :role => { :collection => { :sort => :get, :update_sort => :put } },    :rule => { :collection => { :update_assignments => :put }, :member => { :update_label => :put } },    :rule_label => {},    :shift => { :collection => { :sort => :get, :update_sort => :put } },    :shift_label => {},    :skill => {},    :staff => { :collection => { :sort => :get, :update_sort => :put } },    :task => {},   }

  resource = {     :config => {},     :role_shift => {},     :shift_config => {},   }

  resources.each do |entity, options|     map.resources entity.to_s.pluralize, {       :controller => "preset_project/#{entity}",       :name_prefix => 't_project_',       :path_prefix => '/:enterprise_code/:m_hierarchy_id/:t_project_id',       :requirements => { :m_hierarchy_id => /\d+/, :t_project_id => /\d+/ },     }.merge(options)

    map.resources entity.to_s.pluralize, {       :controller => "preset_project/#{entity}",       :name_prefix => 't_preset_',       :path_prefix => '/:enterprise_code/:m_hierarchy_id',       :requirements => { :m_hierarchy_id => /\d+/ },     }.merge(options)   end

  resource.each do |entity, options|     map.resource entity, {       :controller => "preset_project/#{entity}",       :name_prefix => 't_project_',       :path_prefix => '/:enterprise_code/:m_hierarchy_id/:t_project_id',       :requirements => { :m_hierarchy_id => /\d+/, :t_project_id => /\d+/ }     }.merge(options)

    map.resource entity, {       :controller => "preset_project/#{entity}",       :name_prefix => 't_preset_',       :path_prefix => '/:enterprise_code/:m_hierarchy_id',       :requirements => { :m_hierarchy_id => /\d+/ },     }.merge(options)   end

  ### Project::*

  %w( optimize report sheet ).each do |controller|     map.connect ":enterprise_code/:m_hierarchy_id/:t_project_id/#{controller}/:action/:id",       :controller => "project/#{controller}",       :requirements => { :m_hierarchy_id => /\d+/, :t_project_id => /\d+/ }   end

  ### Preset::*

  map.connect ':enterprise_code/:m_hierarchy_id/:controller/:action',     :requirements => { :m_hierarchy_id => /\d+/,       :controller => %r!preset/top! }

  ### Site::*

  %w( demand project schedule ).each do |controller|     map.connect ":enterprise_code/:m_hierarchy_id/#{controller}/:action/:id",       :controller => "site/#{controller}",       :requirements => { :m_hierarchy_id => /\d+/ }   end

  ### Master::*

  resources = {     :account => {},     :event => {},     :hierarchy => {},   }

  resource = {     :system_constant => {},   }

  resources.each do |entity, options|     map.resources entity.to_s.pluralize, {       :controller => "master/#{entity}",       :name_prefix => 'm_',       :path_prefix => '/:enterprise_code/:m_hierarchy_id',       :requirements => { :m_hierarchy_id => /\d+/ },     }.merge(options)   end

  resource.each do |entity, options|     map.resource entity, {       :controller => "master/#{entity}",       :name_prefix => 'm_',       :path_prefix => '/:enterprise_code/:m_hierarchy_id',       :requirements => { :m_hierarchy_id => /\d+/ }     }.merge(options)   end

  %w( enterprise_config ).each do |controller|     map.connect ":enterprise_code/:m_hierarchy_id/#{controller}/:action/:id",       :controller => "master/#{controller}",       :requirements => { :m_hierarchy_id => /\d+/ }   end

  ### Global::*

  %w( password queue ).each do |controller|     map.connect ":enterprise_code/#{controller}/:action/:id",       :controller => "global/#{controller}"   end

  ### Login

  map.connect ':enterprise_code/:controller/:action',     :controller => 'login',     :enterprise_code => '__default__',     :requirements => { :controller => /login/ }

  ### Stylesheets, Javascripts, Monitor

  map.connect 'stylesheets/actions/:action.css', :controller => 'stylesheets'   map.connect 'stylesheets/:action.css', :controller => 'stylesheets'   map.connect 'javascripts/:action.js', :controller => 'javascripts'   map.connect 'monitor/:action', :controller => 'monitor' end

router settings are quite complex for me, I couldnt understand how to add button and selection to my page. I run the plug in without selection on this page but that time I had tiny problem like, the converter created output file but didnt redirect to main page and didnt ask me save as option. even it runs the converter I need to get the parameter from selection..

hello,

This is not beginner s question topic any more (^-^). Do you have yahoo messenger? because i need to read your script in orginal file. Here your script is untidy.

Visit Indonesia 2008 wrote:

hello,

This is not beginner s question topic any more (^-^). Do you have yahoo messenger? because i need to read your script in orginal file. Here your script is untidy.

*~*~*~*~*~**~*~*~*~*~* Reinhart Ariando Yahoo Messenger ID : Booking2Heaven WEB : http://teapoci.blogspot.com

let me download it. may I add you to my list.we may discuss there.