« first day (1383 days earlier)      last day (1872 days later) » 

7:15 AM
hi guys.
 
 
4 hours later…
11:18 AM
I want a default value for a model. Hiere is what I wrote: create_table :ethics do |t|
t.integer :progress, default: 0 ... end. But this does not work. How do I set the default for integer? Thanks
 
11:34 AM
@metaphysiker ... I've not tested this, but I'm guessing you need to put that 0 in double quotes ... default: "0" as it gets fed into the db. Otherwise, switch to a known working syntex .... stackoverflow.com/questions/1186400/… in the documention edge guides, I can only find change_table_column syntex ... guides.rubyonrails.org/active_record_migrations.html
 
For all of the commands
 
11:55 AM
3 ideas ... test case is STRIPE. Service Locator/Register versus Rails Engine to mount ... Service Object or (DHH)'s method of "custom controller action implies you should, spin off a new controller with that action name - Link
I'm trying write more modular with rails - I can stick anything in a module, but with rails engines mounted in a module I can capture the DHH method too. I don't think the rails engines are worth it unless you're working the model/db frequently.
 
@Mirv Winding back slightly, you do not have to quote 0
@Metaphysiker The way you've written it is exactly correct. You need to elaborate on what "does not work"
 
roger @meagar, ty, I see no quotes on some of the examples on S/O, but I've never used it - my only other guess would be meta's not listed which action he's using for the migration he wrote
Hey Meagar, when you wrote your test app to get hired, did you DRY/module/service object etc or just turn out a bunch of controllers?
 
12:18 PM
Which test app is that?
At Shopify I didn't write a Rails app, just a plain Ruby app
 
ah!, I believe that was the one you mentioned last month
 
Which did not use controllers or service objects :p
 
... if you did do a rails setup - how indepth do you go? Would you be setting defaults, checking for non-zero, dipping into phone # formatting, test mocks for CC/stripe type stuff?
 
12:56 PM
Heeey
 
Morning everyone
 
Morning @Marc-Andre
 
hi guys
 
1:17 PM
@Mirv That depends on how much time I had
 
Gotcha...but you'd roll the controllers/model/db/default tests first add any necessary tests, some basic validation & maybe implement a service class or two to prove you can? or would you harden the application before going for a service class?
 
1:58 PM
Based on this code ...

Class User
has_many :parents, :through => :children_parents, :uniq => true
end

Will this will only enforce uniqeness on the entire table or just `parents` belonging to a particular user?

NM...https://stackoverflow.com/questions/5846638/how-to-display-unique-records-from-a-has-many-through-relationship
 
Good morning, all.
 
Good morning
 
hi
 
@meagar "Just plain Ruby" is the most fun you can have programming. Other than assembly language, I suppose.
 
2:16 PM
what's the fastest rails way to automatically shovel a hash of AR id's of created rows into another table? ie: hash: {:user => "3", :campaign => "2342"} & have this information grabbed by key then put into the Another_Table.new()? ...I'm leaning towards merging in the params.require portion, but curious if there's a straight rails way that's better
 
A view, or a trigger, or activerecord hooks. Why do you want to do that?
 
Right now, my enrollment gem I'm writing calls activerecord directly to make all the rows in question (campaign/user/dashboard/player/country id's) then saving the key/value pairs in a hash. I'm trying to start extracting out the AR element & the first test of that is to make the tracking table populate by the rails controller rather than the gem calling the AR itself
I could just keep it as a rails gem & have the tracking table filled by the gem calling AR too (it would be way faster for me to program) ... I'm following along poodr from metz trying some abstractions basically & this is test, but I was curious how real programmers handle the passing of ruby hashes to AR
I'm also open to suggestions on accomplishing this one ... it would be in a rails controller or model I feel like being most appropriate since it's not view logic & i'd like to avoid triggers unless absolutely necessary
 
2:34 PM
Why "saving the key/value pairs in a hash?"
 
I'm not tied to the 'hash' (array is fine or are you saying there's other methods besides saving the transaction data?) idea, just thought it would be easiest to deal with since rails has super support for json etc & that helps with porting code across APIs which the enroller will probably run on once I get the gem fully extracted & running
 
I have many questions
 
:)
I'm basically writing an admin mod extension (from scratch) for signing up people to games (mostly for my use)...that allows a register user to join games of their choice or host them & such
 
Why are you storing a hash in a database?
Doing that sort of thing is a "break glass in case of emergency" technique. Sometimes needed, but not the first thing one should try.
 
Oh, i'm not ... the hash is what they are held in my object...but the use case is that I will have an object handing a dynamically changing list of keys/values (hash/array/struct/etc) to another object or the AR object (via rails controller) to then insert the variables into the matching column names on a table
 
2:40 PM
What is "they" in this context? "The hash is what they are held..."
 
I'm glad you're not; sorry I jumped to conclusions.
 
Np wayne :)
Cereal, they is .... campaign/user/dashboard/player/country id's, but the names of the columns will change for the project based on the initialization file that provisions the rails AR migration (eventually)
 
So the hash is { the_id => the_object } ?
 
hash: {:user => "3", :campaign => "2342" ....etc}
 
ah
And that hash is what you're referring to when you say "tracking table"?
 
2:46 PM
tracking table is the table in the activerecord db that receives the hash listed above
 
So tracking table will have the columns "user_id, campaign_id... etc"?
and you're wondering how someone might take a hash and map it to that table?
 
short version yes ... the long version is the user of the gem will setup the table & its column names in the initialization file for rails to configure what to call them, then my code base reads them, generates the info based on what it's given, makes the records & records the record id's into the tracking table for later use/review
 
Right, but at runtime, the keys will match the column names
 
yea
idk why, but this type of thing makes me feel giddy
 
Are you just creating a new record?
 
2:51 PM
yes, well like 5-7 new records, then a single row/record on the tracking table of them
(I'm not sure how much I should be extracting at once as my tests are pretty primitive)
 
You can just do TrackingTable.update your_hash
or create, or whatever
assuming that's what you're asking
or are you asking how to create the table in the first place
 
I think I've got the migration stuff, done it twice else where, though haven't used it with initializer...its mostly I got some errors on the .merge & wondered if I had to .map etc instead
I'll take a wack at the .create though! ty (rails uses strong_params with a .require etc to stop mass assignment attacks & sometimes that's problematic)
 
You didn't answer my question :(
 
No, i'm not looking to get info on how to create a table or row - just how to inferface that hash to the creation
 
So you were looking to create the row?
 
2:55 PM
I probably had a syntax issue
but after 3 hours - wanted to ask about it incase i'm chasing up the wrong tree
 
You didn't answer my question again ;_;
I'm just trying to be un-confused ;;
 
Hey all, I just noticed someone is making a connection to the server in code
and they have the password there
in the YML file
shouldn't the password be hidden? Or do you just insure that the git repo is private?
 
Restate the question cereal?
 
Just tell me if I have this right.

You want to create a table based on a config file.

You want to have a hash that corresponds to said table.

You want to be able to create a row in that table with said hash.
 
@qaispak ... we were chatting about this last week, launchschool.com/blog/… & brandonhilkert.com/blog/… offer a light & a deeper view on handling passwords securely in code
Cereal - yes
 
3:01 PM
which one is the lighter one :D
 
Now, was your question how to do step 1, 2, 3, or all of the above
 
Qaispak, the first
Cereal - #3 - I want to get that down first, then #2....I've done #1 already a few times, though I do part with migrations in the rails engine & part with the initializer file
 
Alright
If you have a table with columns a, b, and c
You can just pass a hash such that { a: a_val, b: b_val, c: c_val } to the create function on the table
h = { a: 1, b: 2, c: 3}
SomeTable.create h
 
    aye ... I think the .create/.update were failing due to strong_params [Link](api.rubyonrails.org/v5.0/classes/ActionController/…), so I needed to permit them in the right nesting format...

        def campaign_registration_params
          params.require(:campaign_registration).permit(
              :campaign_id, :user_id, :dash_id, :user_id,
              countries_attributes: [:id, :name, :description, :size],
              players_attributes: [:id,:screenname, :country_id, :motto])
 
@qaispak Passwords should not be checked into git.
 
3:09 PM
There's some extra in there as the show action gives a nested table for editing if the player wants to review/correct anything ... so ignore countries_attributes & players_attributes
 
@WayneConrad , of course but I was wondering if it's okay to have it in your YML file or is not checking it in enough
 
I put passwords in the database.yml file sometimes, and just make sure it's not checked in. Also ensure that it's not world readable.
Other times I put passwords in the environment, and have the database.yml file read them from the environment.
  production:
    <<: *default
    host: wagnerite.internal.virtusmart.com
    port: 3306
    username: db_convert
    password: <%= ENV.fetch("WAGNERITE_DB_CONVERT") %>
    database: admin_inst_base
This is from a non-Rails project, where I run database.yml through the erb engine so I can embed code in it, but I think this will work in Rails.
I think the latest Rails has a dedicated file to put secrets in, actually.
 
Qaispak/Wayne .... secrets.yml is the file - it's described in both of the links along with gems that make it all super easy to do (although, let me just say, psql makes me scream sometimes)
 
Thanks @Mirv
 
rails question again - would you guys do a dirty long link_to 'stuff', {controller: Something, action: Something}, {class: "whatever", id: params[:id]} in the view, stick the dirty part in a helper or make an action & then redirect from the action to the other controller?
 
I'd just write the html lol
Or haml in my case. %a.some_class#some_id(href="/some/url")
 
helper
 
Rails confuses me
 
You're not alone.
 
3:37 PM
helpers are supposed to remove non-essential logic ...in this case from views
Gah, I really like the create a custom action that routes to other controller...having trouble deciding how to link_to to ensure the campaign_id travels with it as rails is magically doing it for me currently
 
4:05 PM
bingo, got it - wasn't super dark magic was just being set in the before_filter
 
5:01 PM
ok, I've been using has_many through relationships pretty much exclusively, but dislike they way rails only does references in migrations to make belongs_to with no switch for making it a has_one or has_many etc
 
has_one and has_many is strictly a model thing. There's no such thing in the database itself.
The database just knows about belongs_to, really.
 
Correction, when generating a scaffold/model w/ rails g {model/scaffold} {name} {column_name}:references - I dislike ....
 
I don't use scaffolds, which is probably why I didn't notice.
 
I believe you can call models in the same way to auto generate & have it put primary keys on it (then rails assumes indexes, but I am not sure if they took that out in 5.0 versus 5.1...)
rails g scaffold campaignRegistration user:references dash:references campaign:references player:references country:references

class CampaignRegistration < ApplicationRecord
  belongs_to :user
  belongs_to :dash
  belongs_to :player
  belongs_to :country
  belongs_to :campaign
end
 
It takes as much time to use the scaffold as it does to just type the model out. More time, because with the model I can use editor tricks that my shell doesn't have.
 
5:11 PM
i just user:r+tab (i get everyone's got different methodologies too - i'm just looking to stack more stuff on top of it later that's why i'm investing in learning rails - doing my own scaffolds is after the gem initializer files)
 
Maybe i should do that before though...might be useful in context of complications
 
 
1 hour later…
6:19 PM
has anyone used websphere MQ?
writing code to push a message to it now.
Should be interesting.
 
may the force be with you
 
6:48 PM
okay... this is way too complex.
even installing this is a nightmare.
 
What is "this"?
 
getting this gem to work.
I am gonna give it one more shot...
 
Its got 17 forks & 29 stars...maybe other's have working examples?
 
My fear is I will keep running into issues and have no one to help.
Giving it a go though. Main issue is configuring IBM websphere
also Moral is down as I couldn't get Maven to work earlier for my java haha
 
yea - once you dig around, you can try to form better questions for your team?
 
6:57 PM
team doesn't care :(
I'm trying to make something impressive from the stuff I've been handed though
to get their attention.
connections to the MQ are dirty. I could use this gem and make it clean!
and fast.
 
@qaispak I'm a Java and Maven guy if you need any help
 
Thanks @Marc-Andre. I believe the issue is with our local setup at work.
 
Ok good, but really the offer is up to anyone who needs help! I can't guarantee that I can answer but I sure will try :)
 
if you're online tomorrow I will definitely need help
Maven seems like a total monster
I like Java but Java + maven is scary
of course ruby I love the most :D
 
Yeah kinda scary, but it's still a powerful tool
 
7:05 PM
at my last internship, as a student who had only written self contained classroom java projects, I was dumped with this huuuuge project with maven, spring, hibernate and what not with no other developers there to explain it to me. It was torture!
 
Yeah it is, it's pretty opaque, lots of classes inheriting lots of abstract classes bunch of magic. The thing is rails magic works great on it's own, not so much on the java side :P
 
@qaispak Do you have to use MQ? I ask because RabbitMQ has a pretty good interface with Ruby.
It's also pretty simple to get working.
 
What is RabbitMQ? The app at work uses Websphere MQ I believe.
lemme google that
oh this looks leaner...
 
I used it at the previous gig. It pretty much just works.
 
Maybe I can connect to rabbibtmq and then that can connect to webbsphere?
or would that be too complex.
 
7:17 PM
No, if your work is using websphere, you're probably stuck with it.
 
ah.. bboo.
 
@qaispak I didn't know your image was someone "famous", I always thought it was you.
 
haha I wish!
 
7:48 PM
Okay the MQ servers don't even have any downloads for OSX. Done with this.
 

« first day (1383 days earlier)      last day (1872 days later) »