Presentation is loading. Please wait.

Presentation is loading. Please wait.

Views Carol Wolf Computer Science. Extended Ruby  Views files are written in extended Ruby, erb.  They end in.html.erb.  Ruby code is intermixed with.

Similar presentations


Presentation on theme: "Views Carol Wolf Computer Science. Extended Ruby  Views files are written in extended Ruby, erb.  They end in.html.erb.  Ruby code is intermixed with."— Presentation transcript:

1 Views Carol Wolf Computer Science

2 Extended Ruby  Views files are written in extended Ruby, erb.  They end in.html.erb.  Ruby code is intermixed with html.  It is enclosed by  Some code adds and ‘=‘ sign, as in.  This guards against a sequel injection attack.  Ruby control blocks require the keyword, end.  Lining up control statements with corresponding ends is tricky.

3 Forms  Forms have been part of html for a long time.  They are used to send parameters to the server. Size Color  Forms have a method, action, text input and a submit button.

4 Methods  Get – Used for moving from one page to another  Parameters are sent in the URL string  Rails uses get for path changes  Post – Used in forms  Parameters are sent in the packets  Rails requires post when using forms  Head, Put, Delete, Trace and Connect  See http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.htmlhttp://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html  Of these, Rails uses Put and Delete.

5 Actions  The action tells the server which controller method should be executed.  Example: action="http://localhost:3000/store ">  Example from Pace Portal  Example from schedule {:action => :list_courses} do |form| %>

6 Text Fields  Text fields are used to collect information. Color  In extended Ruby we would write: Color: 20 %>  The label is used to tell the client what to enter.  The size attribute determines how many characters are to be allowed.  The value attribute is empty in the html and doesn’t even appear in the extended Ruby.

7 Buttons  The submit button is standard for forms.  In Rails this becomes  The value attribute in the first example determines what will be displayed on the button.  In Rails, all you have to do is put the value in quotes, "Send“.  In Rails you can have other buttons as well; we use button_to and have to detail the value and action.

8 The Resulting Code Size: Color:

9 Layouts Rails supplies a layout for every application. Testapp

10 Layouts  The application layout is added to the application, with the code that comes before the listed first.  The Ruby command, yield, tells the application to add in the code in the ERB file.  The last two lines are then added to the end.  The result is a complete html page with a header and footer.

11 Cascading Style Sheets  Styles such as B for bold can be added directly into the html code. Any in the code are always done first.  Styles can also be added into the head of the page in a specific style section. Styles in the body of the html have precedence over these.  Finally styles can be incorporated into a style sheet with extension.css. This is strongly recommended by developers.  The format is very simple. The html tag comes first followed by curly braces. The styles are listed inside the braces, separated by semicolons. And each style is separated from its value by a colon.  Style sheets can be added to the public/stylesheets folder. They will all be added in by Rails.

12 A sample style sheet for tables table{ border: 1; border-style: solid; border-width: thin; cellpadding: 10; } td { border-style: solid; border-width: thin; padding-right: 0.5cm; }


Download ppt "Views Carol Wolf Computer Science. Extended Ruby  Views files are written in extended Ruby, erb.  They end in.html.erb.  Ruby code is intermixed with."

Similar presentations


Ads by Google