# Beginner s question

**URL:** <https://www.ruby-forum.com/t/beginner-s-question/129500>\
**Category:** Rails\
**Created:** [February 19, 2008, 3:55am UTC](https://www.ruby-forum.com/t/beginner-s-question/129500 "2008-02-19T03:55:50Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![casid](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/47e85d/32.png) [@casid](https://www.ruby-forum.com/u/casid)\
**Post date:** [February 19, 2008, 3:55am UTC](https://www.ruby-forum.com/t/beginner-s-question/129500/1 "2008-02-19T03:55:50Z")

</div>

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 + “#{i}”  
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.

---

<div class="post-metadata">

**Author:** ![casid](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/47e85d/32.png) [@casid](https://www.ruby-forum.com/u/casid)\
**Post date:** [February 19, 2008, 4:12am UTC](https://www.ruby-forum.com/t/beginner-s-question/129500/2 "2008-02-19T04:12:36Z")

</div>

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 +  
“#{i}” +  
“#{your\_description}”

end  
%\>

OR

\<%  
templateOptions = “”  
@templates\_array.each do |i|

templateOptions = templateOptions +  
“#{i}” +  
options\_for\_select([“1”, “2”, “3”, “4”], “1”)  
end  
%\>

I hope it can answer your doubtful. Good Luck.

_~_~_~_~_~\*\*~_~_~_~_~_  
Reinhart Ariando  
YM : Booking2Heaven  
WEB : [http://teapoci.blogspot.com](http://teapoci.blogspot.com)

---

<div class="post-metadata">

**Author:** ![casid](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/47e85d/32.png) [@casid](https://www.ruby-forum.com/u/casid)\
**Post date:** [February 19, 2008, 6:05am UTC](https://www.ruby-forum.com/t/beginner-s-question/129500/3 "2008-02-19T06:05:15Z")

</div>

\<%- 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’ %\>

\<%= 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’ %\>

\<%- end -%\>

 &nbsp;&nbsp;&nbsp;&nbsp; \<%=h \_('-- è¨­å®šãƒ¡ãƒ‹ãƒ¥ãƒ¼ --') %\> \<%=h \_('Staff') %\> \<%=h \_('Shift') %\> \<%=h WO::Util.tree\_child + \_('é«˜åº¦ãªè¨­å®š') %\> \<%=h WO::Util.tree\_child + (\_('%sã®ä½œæˆ') % \_('Label')) %\> \<%=h WO::Util.tree\_last\_child + \_('æ¥­å‹™ãƒã‚¤ãƒ³ãƒ‰') %\> \<%=h \_('Location') %\> \<%=h \_('Role') %\> \<%=h \_('Skill') %\> \<%=h \_('Task') %\> \<%=h \_('t project custom count') %\> \<%=h \_('t project config') %\> \<%=h \_('%sã¸ã®åæ˜ ') % \_('Preset') %\> \<%=h \_('%sã®ãƒ­ãƒ¼ãƒ‰') % \_('Preset') %\> 

| \<%=h \_('å¯¾è±¡ã‚µã‚¤ãƒˆ') %\> | \<%=h current\_project.site.name %\> | \<%=h \_('TProject|Name') %\> | \<%=h current\_project.name %\> |

 \<%= 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' %\> 

 \<%= print\_tab \_('Optimize') + ' \>\>', { :controller =\> '/project/optimize', :ac =\> @access\_code }, false, :id =\> 'tab\_optimize' %\> 

\<%= render :partial =\> 'work\_sheet' %\> \<%= render :partial =\> 'calendar\_sheet' %\> \<%= render :partial =\> 'staff\_sheet' %\> \<%= render :partial =\> 'demand\_sheet' %\>

 \<%- if current\_account.system? || current\_account.enterprise? -%\> \<%- end -%\> 

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…

---

<div class="post-metadata">

**Author:** ![casid](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/47e85d/32.png) [@casid](https://www.ruby-forum.com/u/casid)\
**Post date:** [February 19, 2008, 6:27am UTC](https://www.ruby-forum.com/t/beginner-s-question/129500/4 "2008-02-19T06:27:23Z")

</div>

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](http://teapoci.blogspot.com)

---

<div class="post-metadata">

**Author:** ![casid](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/47e85d/32.png) [@casid](https://www.ruby-forum.com/u/casid)\
**Post date:** [February 19, 2008, 6:44am UTC](https://www.ruby-forum.com/t/beginner-s-question/129500/5 "2008-02-19T06:44:16Z")

</div>

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](http://teapoci.blogspot.com)

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