SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    Mar 2014
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    using html.erb as a stand alone file

    HI

    I know this isn't good practice and certainly not what rails is all
    about but is this possible. I need to customize my CRM to use stripe
    which it doesn't support at present.the CRM is written in Ruby and has a
    number of rhtml pages.

    Can I add my own display page of html.erb extension to these pages to receive a variable on one of the CRM's
    existing pages written as: <%= (basket.to_f_withvat).to_money %> On this stand alone page. I can then assign this variable:
    'basket_total = (basket.to_f_withvat).to_money' and then use this to pay with the Stripe
    Gateway as below

    Code Ruby:
    begin
      charge = Stripe::Charge.create(
        :amount => basket_total, # This is your value as a variable.
        :currency => "usd",
        :card => token,
        :description => "payinguser@example.com"

    ---- etc
    Again I know this isn't what RoR and MVC is all about, but it's the only
    way I can think of doing this.

    Thanks
    Last edited by Mittineague; Mar 13, 2014 at 11:37. Reason: reformatting bbcode tags

  2. #2
    padawan silver trophybronze trophy markbrown4's Avatar
    Join Date
    Jul 2006
    Location
    Victoria, Australia
    Posts
    4,117
    Mentioned
    28 Post(s)
    Tagged
    2 Thread(s)
    Hi there,

    What is your CRM package?
    I don't see a reason why you can't hack the code, I think .rhtml is just the older extension for .erb so that same code should work in an .rhtml file.

  3. #3
    SitePoint Member
    Join Date
    Mar 2014
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Its HostPay used through HeartInternet. I agree its should be possible, It;s just that i cant figure out a way to do it without using a controller and a route as is required with RoR. I was wondering id there was a way to do this by putting all the code in just the one page.

  4. #4
    SitePoint Member
    Join Date
    Aug 2008
    Posts
    14
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ERB is just a templating language. I see no reason why you can't just add some logic to build what you need. Really, this is all Rails does.

    Based on the docs, it looks like you can create an ERB template with new and then call result to execute it. I haven't tried it, but it looks pretty straight forward. ERB Docs


Tags for this Thread

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
  •