Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
The Journey Fraternity
Nov 25, 2003



I found this on the ground!

Obsurveyor posted:

I prefer sprinkle. Puppet and Chef are horrible nightmares to setup imho because they're designed for huge enterprise deployment, requiring a server just for managing recipes and such.

I've been using Ansible for exactly this reason.

Adbot
ADBOT LOVES YOU

waffle enthusiast
Nov 16, 2007



The Journey Fraternity posted:

I've been using Ansible for exactly this reason.

I've used Puppet extensively; we just started using Ansible for some other tasks in our environment and our devs/ops really like it. I'm not sold on the flexibility of it yet; where are the warts? It seems like it's really easy to poo poo up your Ansible repo with playbooks that rarely-if-ever get run, leading to configuration management rot and a crufty repo. But at least you don't have the "puppet problem" — a single server or two that control your entire environment and that you are deathly afraid of upgrading/changing for that very reason. But it's really cool to hear someone else in this thread is using Ansible.

To bring this back to your original point, though, you are very correct: Use a configuration management system to build boxes. It's all well and good to say "I can just install nginx and unicorn and such by hand. It's so much quicker." But you will eventually either a) forget how you built said box, or more probably b) stop caring. It's important you provide someone else with the ability to replicate your work. Even if it's just future you.

kayakyakr
Feb 16, 2004

Kayak is true

Dangerllama posted:

To bring this back to your original point, though, you are very correct: Use a configuration management system to build boxes. It's all well and good to say "I can just install nginx and unicorn and such by hand. It's so much quicker." But you will eventually either a) forget how you built said box, or more probably b) stop caring. It's important you provide someone else with the ability to replicate your work. Even if it's just future you.

Just because I enjoy playing devil's advocate, you do run a risk, if you rely on a configuration manager, that it goes out of flavor 1-2 years down the road and now you're locked into a configuration app that lacks support, lacks community involvement, and has been replaced by the new flavor of the month.

Ansible came out last year. Chef in '09. Puppet is mature at '05. I hadn't even heard of Sprinkle. Then there's Docker/dokku that's just gaining traction and other "transportable environments." You can really get analysis paralysis looking at all these toolkits. Just be careful that you don't spend more time on deployment tools than you spend on development.

The takeaway: learn how to do it yourself and once you can, do whatever the hell feels comfortable to you, be it using a configuration manager or continuing to do it by hand.

This conversation completely changes in a large team environment. I would use a configuration manager there so you can get a consistent server with some guarantee of idiot-proofing.

Newbsylberry
Dec 29, 2007

I Swim in drag shorts because I have a SMALL PENIS
I know this thread is on its way out, but I was curious if anyone had used this guide to set up devise/omniauth for rails4: https://github.com/plataformatec/devise/wiki/OmniAuth:-Overview ? I know Kayakyakr recommended it earlier in the thread, but I couldn't get it to work in rails4. I am reinstalling devise and having another run, but if anyone knows of any issues or concerns I might run into I would love the help.

more like dICK
Feb 15, 2010

This is inevitable.

Obsurveyor posted:

I prefer sprinkle. Puppet and Chef are horrible nightmares to setup imho because they're designed for huge enterprise deployment, requiring a server just for managing recipes and such.

Puppet is perfectly capable of managing a single machine, without a Puppet Master server. The way I'm using it right now is a shell script that bootstraps puppet on a naked server, grabs my manifests, and applies them. Puppet sets up a cron job to regularly pull and apply manifests from my github.

Obsurveyor
Jan 10, 2003

more like dICK posted:

Puppet is perfectly capable of managing a single machine, without a Puppet Master server. The way I'm using it right now is a shell script that bootstraps puppet on a naked server, grabs my manifests, and applies them. Puppet sets up a cron job to regularly pull and apply manifests from my github.

It's still way, way too many moving parts compared to something like Sprinkle for my needs. If it's more than installing a gem, it's too much and you do have to do system level installation stuff for Puppet, which is a big "Nope!" from me.

waffle enthusiast
Nov 16, 2007



Obsurveyor posted:

It's still way, way too many moving parts compared to something like Sprinkle for my needs. If it's more than installing a gem, it's too much and you do have to do system level installation stuff for Puppet, which is a big "Nope!" from me.

You can install Puppet and Facter as gems and `bundle exec` everything if you prefer. And, as more like dICK has already mentioned, you can run both Puppet and Chef in masterless configuration (I'd actually recommend this configuration to people not managing thousands of nodes).

But more to the point, why would you be averse to installing system-level stuff to…y'know…manage systems? You're going to have to do some minor amount of bootstrapping of any OS anyway. Installing one or two universally available packages shouldn't really be a problem. Where you run into trouble managing puppet/chef versions is when you've got hundreds of nodes that need upgrading; obviously not a problem if you're only managing a few nodes. And when you're managing hundreds/thousands…well, software patching is a problem you've going to have to have solved anyway.

Not to be harsh, but taking a cursory look at Sprinkle, it sure looks a lot like just another "me too" ruby DSL. I don't see what it gives you over already existing options, other than maybe it looks more like pure ruby (though from experience, I'd argue that's not a benefit in the configuration management space, where non-rubyists will usually be playing along).

Obviously in the end you should go with whatever you prefer. And again, I'd stress the only wrong answer is not to use configuration management of some sort. I just wouldn't not pick Chef or Puppet because they're too "enterprise" oriented, or require a server. Neither of those statements is true.

waffle enthusiast fucked around with this message at 05:22 on Dec 31, 2013

Sil
Jan 4, 2007
Any good tutorials on how to do performance testing/benchmarking for Rails? Right now I'm looking at using ruby-prof locally to test specific methods as suggested in the 411 railscast. Additionally I want to build a second app that pumps requests at specific url endpoints. Does that sound reasonable?

kayakyakr
Feb 16, 2004

Kayak is true

Newbsylberry posted:

I know this thread is on its way out, but I was curious if anyone had used this guide to set up devise/omniauth for rails4: https://github.com/plataformatec/devise/wiki/OmniAuth:-Overview ? I know Kayakyakr recommended it earlier in the thread, but I couldn't get it to work in rails4. I am reinstalling devise and having another run, but if anyone knows of any issues or concerns I might run into I would love the help.

Didn't get to work on the new thread over the break.

That should be working with rails 4, is there anything in particular that it's giving you an issue with?

raej
Sep 25, 2003

"Being drunk is the worst feeling of all. Except for all those other feelings."
This may not be the right thread, but I decided to pull the trigger with Digital Ocean and set up a Dokku Ubuntu install for a server to mimic a Heroku like Ruby on Rails environment.

Does anyone have any experience with this? Ideally I'd like to be able to git push to my DO droplet and BAM everything works.

raej fucked around with this message at 03:49 on Jan 5, 2014

Newbsylberry
Dec 29, 2007

I Swim in drag shorts because I have a SMALL PENIS

kayakyakr posted:

Didn't get to work on the new thread over the break.

That should be working with rails 4, is there anything in particular that it's giving you an issue with?

I am getting the pretty common error:

Authentication Failure! invalid_credentials: OmniAuth::Strategies::OAuth2::CallbackError, OmniAuth::Strategies::OAuth2::CallbackError

I have tried setting omniauth-facebook at version 1.4, and some of the other common solutions seen on Stack Overflow, but they aren't working for me.

Edit - I am also wondering if people have a certain "protocol" they follow for writing methods or code they aren't familiar with (everything for me) in order to make it more manageable and possible to break it into parts?

Newbsylberry fucked around with this message at 15:49 on Jan 5, 2014

kayakyakr
Feb 16, 2004

Kayak is true

Newbsylberry posted:

I am getting the pretty common error:

Authentication Failure! invalid_credentials: OmniAuth::Strategies::OAuth2::CallbackError, OmniAuth::Strategies::OAuth2::CallbackError

I have tried setting omniauth-facebook at version 1.4, and some of the other common solutions seen on Stack Overflow, but they aren't working for me.

Edit - I am also wondering if people have a certain "protocol" they follow for writing methods or code they aren't familiar with (everything for me) in order to make it more manageable and possible to break it into parts?

I've had issues with facebook's oauth and working with my localhost, could that be something? I know that it isn't a Rails 4 issue as I have omniauth and devise working fine.

Maybe try debugging in your callback and see what facebook is sending you?

Newbsylberry
Dec 29, 2007

I Swim in drag shorts because I have a SMALL PENIS

kayakyakr posted:

I've had issues with facebook's oauth and working with my localhost, could that be something? I know that it isn't a Rails 4 issue as I have omniauth and devise working fine.

Maybe try debugging in your callback and see what facebook is sending you?

I am testing it on a deployed server, so it's not the localhost issue.

It's the callback phase, but I don't know what I need to change. This is the output from the server:

code:
Started GET "/users/auth/facebook" for 24.59.0.121 at 2014-01-08 04:09:42 +0000
(facebook) Request phase initiated.
Started GET "/users/auth/facebook/callback?code=
AQDF6LwvzPyjHAGszRdF_p69QJToV8eHtM_vRXOfHJsecQOg4CYuP5kGH2VMnH4ABTNoi7Seqs5Ey3hUTTUM3ptXeYa_ZTlwILdvLat0wJ0k2Je_
9bQKl5DFetNr4gU5X53THJiZIORiDx06-8H06N02l$
(facebook) Callback phase initiated.
(facebook) Callback phase initiated.
(facebook) Authentication failure! invalid_credentials: 
OmniAuth::Strategies::OAuth2::CallbackError, OmniAuth::Strategies::OAuth2::CallbackError
here is my callback controller:

code:
class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
  def facebook
    # You need to implement the method below in your model (e.g. app/models/user.rb)
    @user = User.find_for_facebook_oauth(request.env["omniauth.auth"], current_user)

    if @user.persisted?
      sign_in_and_redirect @user, :event => :authentication #this will throw if @user is not activated
      set_flash_message(:notice, :success, :kind => "Facebook") if is_navigational_format?
    else
      session["devise.facebook_data"] = request.env["omniauth.auth"]
      redirect_to new_fridge_ingredient_path
    end
  end
end
here is my user model:

code:
  devise :database_authenticatable, :registerable,
         :recoverable, :rememberable, :trackable, :validatable,
         :omniauthable, :omniauth_providers => [:facebook]

  def self.find_for_facebook_oauth(auth, signed_in_resource=nil)
    user = User.where(:provider => auth.provider, :uid => auth.uid).first
    unless user
      user = User.create(name:auth.extra.raw_info.name,
                         provider:auth.provider,
                         uid:auth.uid,
                         email:auth.info.email,
                         password:Devise.friendly_token[0,20]
                         )
    end
    user
  end

  def self.new_with_session(params, session)
    super.tap do |user|
      if data = session["devise.facebook_data"] && session["devise.facebook_data"]["extra"]["raw_info"]
        user.email = data["email"] if user.email.blank?
      end
    end
  end
I am thinking of going back to rails3 and seeing if that fixes the problem.

raej
Sep 25, 2003

"Being drunk is the worst feeling of all. Except for all those other feelings."
Rails generates a 404.html file to use for all 404 errors. Is there a good way to get this file to use bootstrap? I'd like it to have the same look and feel as the rest of the site without adding a lot of bloat/redundant styling.

A MIRACLE
Sep 17, 2007

All right. It's Saturday night; I have no date, a two-liter bottle of Shasta and my all-Rush mix-tape... Let's rock.

It's been a while since I used a stock rails 404 page, is it located in the public/ directory?

raej
Sep 25, 2003

"Being drunk is the worst feeling of all. Except for all those other feelings."

A MIRACLE posted:

It's been a while since I used a stock rails 404 page, is it located in the public/ directory?

Yes, yes it is! Is there a better way to specify 404 pages elsewhere?

kayakyakr
Feb 16, 2004

Kayak is true

raej posted:

Rails generates a 404.html file to use for all 404 errors. Is there a good way to get this file to use bootstrap? I'd like it to have the same look and feel as the rest of the site without adding a lot of bloat/redundant styling.

You could use a rescue_from in your application controller to go ahead and render a 404 using your application layout. Something like this:

https://gist.github.com/Sujimichi/2349565

Legacyspy
Oct 25, 2008
So I have a rake task that starts:


code:
task :do_stuff, [:list_of_ids,:flag] => :environment do |t, args|
my goal is that I want to pass a list of ids and a flag

rake do_stuff['1,2,3','true']

The problem that I run into is that it takes args[:list_of_ids] to be '1' and args[:flag] to be '2'.

I don't know how to change this.

A MIRACLE
Sep 17, 2007

All right. It's Saturday night; I have no date, a two-liter bottle of Shasta and my all-Rush mix-tape... Let's rock.

Google is your friend http://stackoverflow.com/questions/12055877/how-can-i-pass-an-array-as-an-argument-to-a-rake-task

The simple thing is to just use whitespace delineation instead of commas, then call .split(' ') or whatever on the first argument to get your array

raej
Sep 25, 2003

"Being drunk is the worst feeling of all. Except for all those other feelings."
Anyone running Dokku on Digital Ocean know why I would be getting a "502 Bad Gateway NGINX 1.4.3" error when I push to it, yet the app deploys fine on Heroku?

NGINX log file shows this:

2014/01/10 01:56:32 [error] 2376#0: *1 connect() failed (111: Connection refused) while connecting to upstream, client: <my.ip.add.ress>, server: app.campbellscoop.com, request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:49153/", host: "app.campbellscoop.com

raej fucked around with this message at 01:32 on Jan 11, 2014

Pardot
Jul 25, 2001




Is your application server running on port 49153?

raej
Sep 25, 2003

"Being drunk is the worst feeling of all. Except for all those other feelings."

Pardot posted:

Is your application server running on port 49153?

I ran docker ps and got this

code:
CONTAINER ID        IMAGE               COMMAND                CREATED             STATUS              PORTS                     NAMES
489e35602005        app/test:latest     /bin/bash -c /start    39 hours ago        Up 39 hours         0.0.0.0:49154->5000/tcp   tan_tiger
So 49154? How do I get these to match up?

Mad Wack
Mar 27, 2008

"The faster you use your cooldowns, the faster you can use them again"
I didn't see this in the OP but I'd like to learn more about making web apps with rails. I've only done scripting language work for little automation tools. I learn best through books - is there a book that covers everything after an idea all the way up to a finished web app?

EDIT: Thank you so much!
VVVVVVVVVVVVVVVVVVVVVVVV

Mad Wack fucked around with this message at 22:35 on Jan 13, 2014

EAT THE EGGS RICOLA
May 29, 2008

Mad Wack posted:

I didn't see this in the OP but I'd like to learn more about making web apps with rails. I've only done scripting language work for little automation tools. I learn best through books - is there a book that covers everything after an idea all the way up to a finished web app?

I liked Michael Hartl's tutorial, but I'm not sure if there's something better now. The online book is free, there's a video series you can buy if you like.

Newbsylberry
Dec 29, 2007

I Swim in drag shorts because I have a SMALL PENIS
I am trying to use radio buttons and can't get them to work:

This works locally but when I deploy the checkboxes don't even show up on the site:

code:
<%= f.collection_radio_buttons :drink_type_id, DrinkType.all, :id, :name %><br>
These don't work locally, or when I deploy (neither does radio_button_tag):

code:
<% @drink_types.each do |drink_type| %>
   <%=  f.radio_button :drink_type_id, drink_type.id %><%= f.label :drink_type_id, drink_type.name %>
<% end %>
Any ideas?

Edit - Alright, even though the checkboxes aren't showing up I can still select the drink_type, so I think it's the style sheets, I'm pretty sure I can figure this out.

Amazing, thanks!

VVVVVVVVVVVVVVVVVVVVVV

Newbsylberry fucked around with this message at 04:15 on Jan 15, 2014

The Journey Fraternity
Nov 25, 2003



I found this on the ground!

Newbsylberry posted:

I am trying to use radio buttons and can't get them to work:

This works locally but when I deploy the checkboxes don't even show up on the site:

code:
<%= f.collection_radio_buttons :drink_type_id, DrinkType.all, :id, :name %><br>
These don't work locally, or when I deploy (neither does radio_button_tag):

code:
<% @drink_types.each do |drink_type| %>
   <%=  f.radio_button :drink_type_id, drink_type.id %><%= f.label :drink_type_id, drink_type.name %>
<% end %>
Any ideas?

Edit - Alright, even though the checkboxes aren't showing up I can still select the drink_type, so I think it's the style sheets, I'm pretty sure I can figure this out.

You should check out app/assets/stylesheets/myFridge.css:119-121

Eugenics
Mar 25, 2007
Because I'm better than you
I really really enjoyed mhartl's rails tutorial. The problem is it's so good that it makes the Agile Web Development in Rails book look like utter poo poo. Not only does it use scaffolds, but a fair amount of the code isn't explained very well. So I'm trying to make a shopping cart from scratch like the book does, but I can't seem to find any good tutorials for Rails 4 that aren't just copy/pastes from the Agile book.

Any ideas?

raej
Sep 25, 2003

"Being drunk is the worst feeling of all. Except for all those other feelings."
What is the preferred way to import csv files to populate a database in rails? The Railscast is so old, Roo just craps itself with a NameError and Unitialized Constant.

I checked stackoverflow and found this but it still didn't solve the error, so I don't mind looking at another solution and starting from scratch.

Also, the CSV files are rather large, one if ~40k entries, the other is ~200k entries, so Roo wouldn't be a good option anyway.

KoRMaK
Jul 31, 2012



I'd like to alter the "rails generate Scaffold MyModel" behavior. I need to make changes to the way models and controllers are spit out in addition to creating some new view files beyond the standard index/form/edit/show. As a plus, it would be nice if I could also alter an existing model to add a relationship clause to the new Scaffold-ed model.

I read this top to bottom http://guides.rubyonrails.org/generators.html#first-contact but it hasn't fully clicked and I can't find an implemented example. I'm looking around in my railities folder and think I probably will copy those files for a start.

I'd like to add this behavior in addition to the default scaffold behavior so I can chose when I want to use it. e.g. rails generate Scaffold and rails generate MyScaffold would both work.

Is this possible?

A MIRACLE
Sep 17, 2007

All right. It's Saturday night; I have no date, a two-liter bottle of Shasta and my all-Rush mix-tape... Let's rock.

raej posted:

What is the preferred way to import csv files to populate a database in rails? The Railscast is so old, Roo just craps itself with a NameError and Unitialized Constant.

I checked stackoverflow and found this but it still didn't solve the error, so I don't mind looking at another solution and starting from scratch.

Also, the CSV files are rather large, one if ~40k entries, the other is ~200k entries, so Roo wouldn't be a good option anyway.

Is this a one-time thing? Just script it with the CSV class and the Sequel gem. If it's going to be a common seed thing, use db:seed and refer to the documentation

Smol
Jun 1, 2011

Stat rosa pristina nomine, nomina nuda tenemus.

raej posted:

What is the preferred way to import csv files to populate a database in rails? The Railscast is so old, Roo just craps itself with a NameError and Unitialized Constant.

I checked stackoverflow and found this but it still didn't solve the error, so I don't mind looking at another solution and starting from scratch.

Also, the CSV files are rather large, one if ~40k entries, the other is ~200k entries, so Roo wouldn't be a good option anyway.

Write a 5 line script yourself. There is a CSV parser in the standard library.

Smol fucked around with this message at 23:15 on Jan 16, 2014

Molten Llama
Sep 20, 2006

Smol posted:

Write a 5 line script to do that yourself. There is a CSV parser in the standard library.

And even if Googling suggests FasterCSV, don't use it unless you're on Ruby 1.8.

1.9 and later have merged in FasterCSV and some additional improvements. Stdlib CSV is what you want.

A MIRACLE
Sep 17, 2007

All right. It's Saturday night; I have no date, a two-liter bottle of Shasta and my all-Rush mix-tape... Let's rock.

CSV class isn't even that necessary if all you're going to do is iterate over a .split call

Oh My Science
Dec 29, 2008
I would like to pre-populate a form using a previous pages form values, what's the best way to approach this in rails?

kayakyakr
Feb 16, 2004

Kayak is true

Oh My Science posted:

I would like to pre-populate a form using a previous pages form values, what's the best way to approach this in rails?

If they're values off of an object, build that object each step along the way with the params you have and use form_for.

so it would go:

new (build blank object) -> details (build object with params from new) -> create (create object with combined params)

EAT THE EGGS RICOLA
May 29, 2008

Is there a better guide to publishing gems than this: http://guides.rubygems.org ?

I have a bit of stuff I'd like to throw up but I'm not sure if that one is out of date or if there's another one that is preferred.

hmm yes
Dec 2, 2000
College Slice
What are you using in Rails 4 for authorization? We use (love) CanCan in Rails 3, but the official gem doesn't have Rails 4 support...

A MIRACLE
Sep 17, 2007

All right. It's Saturday night; I have no date, a two-liter bottle of Shasta and my all-Rush mix-tape... Let's rock.

atastypie posted:

What are you using in Rails 4 for authorization? We use (love) CanCan in Rails 3, but the official gem doesn't have Rails 4 support...

It's not like CanCan is that complicated, be sure to check the source but I don't see why it would be an issue

kayakyakr
Feb 16, 2004

Kayak is true

atastypie posted:

What are you using in Rails 4 for authorization? We use (love) CanCan in Rails 3, but the official gem doesn't have Rails 4 support...

I've been using cancan in rails 4 without issue. Rails 4 was really not a huge change. It was mostly to deprecate a bunch of old features and force people onto a ruby > 1.9.


e: I know I started on a new thread, but the holidays and a project got in the way of me working on that. I just wrapped up that other project, but I'm starting a new project today. Still, I'll try to do some stuff.

I'm going to do this section-by-section, first up is Tutorials. Please give me your best learning Ruby tutorials. That's Ruby, Rails, Sinatra, Rack, Rake, anything that you'd like to point people to. So far, I have:

  1. Michael Hartle’s Rails Tutorial

tl;dr: post up tutorials for the new OP.

e2: Reminder, you can help directly by writing in this document

kayakyakr fucked around with this message at 19:37 on Jan 17, 2014

Adbot
ADBOT LOVES YOU

Jam2
Jan 15, 2008

With Energy For Mayhem
I've designed some simple Ruby objects to model a problem and I like the way they're composed. I'd like to use them as the backend for a Rails app and persist the data to a database. How can I integrate this design into rails without having to make these classes inherit from ActiveRecordBase and tangle them together with the RailsWay of doing associations? Is that really the way to go? Ideally, I'd like to integrate this in a way such that the objects, at most, have some other object that they persist themselves to. I don't want to uglify this with Rails code. HALP!

code:
class Entity
  attr_accessor :description
  def initialize description
    @description = description
  end
end
code:
require 'interval'

class Group
  attr_reader :expenses
  attr_reader :memberships

  def initialize
    @expenses = []
    @memberships = []
  end

  def add_transaction e
    @expenses << e
  end

  def add_membership p
    @memberships << p
  end

  def balances
    Hash.new(0).tap do |balance_hash|
      expenses.each do |e|
        summ = 0
        rms = responsible_memberships(e)
        rms.each do |rp|
          summ += e.interval.overlapped_by rp.interval
          balance_hash[rp] = e.amount * summ / rms.size
        end
      end
    end
  end

  private
  def responsible_memberships e
    Array.new.tap do |rms|
      memberships.each do |p|
        fraction = e.interval.overlapped_by p.interval
        if fraction > 0
          rms << p
        end
      end
    end
  end
end
code:
class Interval
  attr_accessor :finish # because 'end' is reserved
  attr_accessor :start

  # initialize with two Ruby Time objects
  def initialize start, finish
    @start = start
    @finish = finish
    raise ArgumentError.new("invalid range") if (finish - start) < 0
  end

  # returns a float in range [0, 1] denoting the fraction overlapped by |other|
  # FIXME make sense of the math => make it pretty => make it fast
  # TODO careful with edge case where other start == this finish 
  def overlapped_by other
    return 1 if other.start <= start and other.finish >= finish
    return 0 if other.start > finish or other.finish < start
    num_secs_within_interval = (other.start - start)
    if other.finish < finish
      num_secs_within_interval = num_secs_within_interval - (finish - other.finish)
    end
    return num_secs_within_interval / dur
  end

  private
  # duration: the number of seconds (as float) elapsed within an interval
  def dur
    finish.to_f - start.to_f
  end
end
code:
class Membership
  attr_accessor :entity
  attr_accessor :interval

  def initialize entity, interval
    @entity = entity
    @interval = interval
  end
end
code:
class Transaction
  attr_accessor :amount 
  attr_accessor :description
  attr_accessor :interval

  # initialize with a float |amount| and instance of Interval
  def initialize amount, interval, opts = {}
    @amount = amount # currently float, TODO implement Money
    @description = opts[:description] if opts[:description]
    @interval = interval
  end
end

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply