SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Hybrid View

  1. #1
    SitePoint Evangelist
    Join Date
    Apr 2005
    Posts
    485
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Not Railsy, But... How Do You...

    i'm workign through agile web dev with rails. i understand the scaffold and that it generates forms based off of your db definitions.

    i'm curious how one would structure an app (or portion thereof) that didn't use a db? let's say i wanted an input box like so...

    Enter Number: [text box here]

    [Enter link here]

    i would then like it to then display a different page with the number multiplied by 2. i know the math s/b stuck in the controller. i think ruby has a post method, but i don't know how to use it.

    how would i display the result in the same page?

    general answers with code snippets would probably be sufficient.

    tia...

  2. #2
    SitePoint Guru
    Join Date
    Aug 2005
    Posts
    986
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You create one input page with the form:

    Code:
    <input type="text" name="number" />
    and then the action (the form should post to this action):

    Code:
    def multiply
       @number = params[:number].to_f * 2
    end
    multiply's view:

    Code:
    The number * 2 = <%= @number %>


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •