Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have created a simple application and edited the index.erb file so that I have a simple view with a text box and a button.

Now when i click on that button i want it to navigate to a new view. I know that we can add models and in that models we have different .erb files. but i want to create a single .erb file or add it to an existing model so that i can change edit the view and call that view as i press the button.

Is it like for every screen we have to create a model??

I dont know how to do the same, i tried searching but no help so far.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
479 views
Welcome To Ask or Share your Answers For Others

1 Answer

No you don't have to create models for each view(.erb). In case you want to add new view to existing model, just add new method(def) into the controller(.rb), and new view(.erb) with the same name as of the new method.

let say there exist a model DemoController.rb in app/Demo. you can add new method to it as like

class DemoController < Rho::RhoController
  ...
  def index
  end

  def new_method
  end

end

To navigate from the index view to the new_method, you can write

<button onclick="location.href='/app/Demo/new_method'">new method</button>

or

<button onclick="location.href='<%= url_for :action => :new_method %>'"
>new method</button>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...