Activity Graph

Page 1 of 9 | Next »


[19:10:19] masscrx: has joined #RubyOnRails
[19:13:38] masscrx: I have some question regarding activemodel serializer, I want to get from API user with related department in json format like a { user: { user_departments: [ {id: 1, name: 'department 1', department_id:3} ] } }, user has_many departments through user_departments
[19:14:39] masscrx: I need a department's id from user_departments table for user's nested attributes
[19:17:03] masscrx: with jbuilder I would do that by:
[19:17:05] masscrx: json.user_departments_attributes @user.user_departments do |user_department|


[22:04:22] masscrx: Ping timeout: 260 seconds


[18:26:36] masscrx: has joined #RubyOnRails
[18:28:24] masscrx: I have a strange problem with rake, I have defined rake task and when I invoke by command line task runs correctly, but when I'm trying to run that task from model callback then there is no action
[18:29:28] masscrx: Rake::Task["crm:db:migrate"].execute() - NoMethodError: undefined method `db_user' for nil:NilClass and thas fine I can see that task is invoking
[18:30:01] masscrx: but when Rake::Task["crm:db:migrate"].invoke() - then no errors, no logs, nothing, just no action
[18:30:26] masscrx: any ideas ?
[18:31:00] masscrx: I was trying system("rake crm:db:migrate database_name=#{db_name}") but resulted some errors
[18:39:07] masscrx: yes my schema is dynamic
[18:39:39] masscrx: I can run migrations for specific database passed as argument


[15:10:51] masscrx: *.net *.split


[20:29:50] masscrx: Ping timeout: 276 seconds
[20:30:03] masscrx: has joined #RubyOnRails


[19:06:30] masscrx: Remote host closed the connection


[15:26:35] masscrx: has joined #RubyOnRails


[20:47:17] masscrx: *.net *.split


[07:39:29] masscrx: Ping timeout: 250 seconds
[07:39:36] masscrx: has joined #RubyOnRails


[10:28:09] masscrx: has joined #RubyOnRails
[10:30:53] masscrx: hi, I've just started to learning testing RoR apps, and Im bit lost with naming "unit/test/feauture", for example I would like to test user login with sorcery gem, there is a doc about it: but I dont understand which way should I go, TestCase/Functional Tests/Feature Tests ?
[10:32:16] masscrx: so should I make it as feauture tests or functional tests? or both ?


[17:20:46] masscrx: *.net *.split


[16:17:32] masscrx: Ping timeout: 272 seconds
[16:17:40] masscrx: has joined #RubyOnRails


[12:25:10] masscrx: *.net *.split
[12:29:46] masscrx: has joined #RubyOnRails


[01:45:33] masscrx: has joined #RubyOnRails


[13:56:02] masscrx: *.net *.split


[00:05:18] masscrx: has joined #RubyOnRails
[14:12:56] masscrx: Ping timeout: 272 seconds
[14:13:23] masscrx: has joined #RubyOnRails


[09:50:03] masscrx: *.net *.split


[15:45:15] masscrx: Ping timeout: 260 seconds
[16:47:56] masscrx: has joined #RubyOnRails


[09:33:53] masscrx: Ping timeout: 264 seconds
[09:35:16] masscrx: has joined #RubyOnRails
[14:02:08] masscrx: I have given params: Parameters: { "offer"=>{"name"=>"example offer", "limits"=>{"shops"=>"1", "items"=>"15"}}, "commit"=>"Create Offer"}
[14:02:17] masscrx: and params.require(:offer).permit(:id, :name).tap { |whitelisted| whitelisted[:limits] = params[:offer][:limits] }
[14:02:32] masscrx: but there is still info about unpermitted parameters
[14:03:01] masscrx: any advice?
[14:03:31] masscrx: Unpermitted parameter: limits
[14:04:43] masscrx: what do you mean where?
[14:04:53] masscrx: in controller by params.require(:offer).permit(:id, :name).tap { |whitelisted| whitelisted[:limits] = params[:offer][:limits] }
[14:07:18] masscrx: so how to permit that hash ?
[14:09:44] masscrx: sevenseacat: so now my request: params.require(:offer).permit(:id, :name, :price, :feauture_id, :limits) and params.require(:offer).permit(:id, :name, :price, :feauture_id, :limits) still :
[14:10:11] masscrx: limits: [] ?
[14:10:26] masscrx: but keys will be dynamic
[14:10:44] masscrx: so I need to permit a hash with unknown keys
[14:11:47] masscrx: sevenseacat: yeah it can be limits: {"shops" => "1"} or limits: {"sales" => "1000"}
[14:12:41] masscrx: but keys are fetched from DB, and are defined by user
[14:13:29] masscrx: sevenseacat: so I need to permit hash without providing keys
[19:01:52] masscrx: *.net *.split
[19:08:08] masscrx: has joined #RubyOnRails


[10:52:10] masscrx: Im trying to create role in postgres database by PG gem's class, so conn = PG.connect( dbname: main_db, host: host, user: username, password: password ) and then conn.exec("CREATE ROLE #{db_username} with LOGIN PASSWORD '#{db_password_plain}'"), how to get result if role was created properly ?
[10:55:21] masscrx: slash_nick: its possible but I have another queries which would be nice to get result
[10:55:33] masscrx: if action is performed succesfully
[14:25:56] masscrx: I would like to use create_database method for postgresql, how to use it ?
[14:26:19] masscrx: Im trying from console irb(main):021:0> db = ActiveRecord::ConnectionAdapters::PostgreSQL::SchemaStatements.
[14:26:25] masscrx: but there is no create_database method
[17:28:57] masscrx: I need some help with associations and database schema, I have customer model with has_one account, account has_many services, and service is connected to offer so 1.I select service ex."Sale" offer ex."Winter offer" with some limits {limit_shops: 1, limit_sales: 100} (hstore type)
[17:29:22] masscrx: how to design db schema and assocs for that
[17:30:32] masscrx: for fetching for example "Winter offer").first.offer.limits
[17:31:36] masscrx: service has one offer
[17:32:42] masscrx: assume that I have services: [sales, crm], and assign 'sale' service to customer, and then create some offer
[17:33:15] masscrx: after some time customer buy 'crm' service and then I can create some custom offer for that service for that customer ;]
[17:34:43] masscrx: offer to service
[17:34:51] masscrx: Account -> Service -> Offer
[17:35:23] masscrx: Customer -> Account -> Service -> Offer
[17:36:29] masscrx: the problem is between Service <-> Offer, because to create Offer I need service, and for service I need offer
[17:36:53] masscrx: Im not sure if it is possible but I need to create table like account_services_offer ?
[17:38:11] masscrx: and offer ... ? belongs_to service or has_many services? I need some join table for that
[17:39:48] masscrx: because I would like to assign "Winter offer" for many customer
[17:39:59] masscrx: for different customers services
[17:44:00] masscrx: Scenario: Customer-1 buy service "Sales" with offer "Winter offer", Customer-2 buy service "Sales" with offer "Summer offer", and Customer-1 can buy additional service "Crm" with offer "Crm - 30 day trial", for Customer-2 the same
[17:46:11] masscrx: - offer is the opportunity of an account to buy one service
[17:49:19] masscrx: hmm Ill try that way
[19:10:16] masscrx: is it ok to have join table for 3 models ? How to handle them ?
[19:11:05] masscrx: I mean writing/quering
[19:12:20] masscrx: I was talking before with another guy but Im not sure how to make model and table for that join table
[19:12:50] masscrx: Account belongs_to :customer, has_many :account_services_offer, has_many :services, through: account_services_offer
[19:13:06] masscrx: Service has_one :offer
[19:13:18] masscrx: and now create table account_services_offer ?
[19:13:31] masscrx: AccountServicesOffer [belongs_to :account, :service, :offer]
[19:13:41] masscrx: is it ok ?
[19:14:31] masscrx: rhizome:
[19:16:07] masscrx: rhizome: but not sure how to design join table and assocs for that 3 models account,service,offer
[19:16:48] masscrx: rhizome: yes
[19:17:31] masscrx: rhizome: Offer will have limits like limit_shops, limit_sales stored as hstore
[19:18:47] masscrx: HMT = Has Many Throught, right ?
[19:19:53] masscrx: rhizome: so how should look like offer table ?
[19:22:36] masscrx: rhizome: so in which table will be stored data with relation account -> service -> offer ?
[19:27:00] masscrx: rhizome: Service describes available rails engines (sales,crm,schedules), Offer describes limits for that engines (how many sales can customer do etc) and now I need to store that information in some table so "Which engines/services customer bought, and which offer for each engine/service" thats why I need join table for that (I guess)
[19:28:28] masscrx: fiu fiu fiu, morning! ;-}
[19:31:46] masscrx: rhizome: so from Admin side, when visiting customer's profile page, he will be able to choose from dropdown some Service and then related offer, and save that 3 informations to table
[19:45:28] masscrx: rhizome: correct ?
[19:49:24] masscrx: rhizome: looks strange but correct for me:P maybe because I treat word "service" as collection of available engines in my project
[19:50:13] masscrx: "services" = available engines instead of bought services by customer, but thats fine
[19:50:56] masscrx: oh yeah exactly ;]
[19:53:10] masscrx: nice thank you


[11:44:03] masscrx: hi, I have some question related to : and They are talking about case when I have main app with loaded devise and engine with devise, but in my case hmm I dont have "main" app, only engines, so engine A,B,C,D will it be possible to have devise loaded on engine A and be separately ? with different config/i
[11:44:31] masscrx: on engine A and B*


[02:23:48] masscrx: has joined #RubyOnRails


[07:03:55] masscrx: Ping timeout: 255 seconds


[15:03:10] masscrx: assume that I have 500 databases on the server and one RoR application, how do you store passwords/usernames ? is it ok to store that much users credentials as ENV[] ?
[15:05:15] masscrx: I have one app engine and want to create for each customer new database
[15:05:56] masscrx: for now assume that there is one VPS, and 500 mysql databases
[15:06:19] masscrx: currently I store credentials on main database, but Ikm thinking what next
[15:07:15] masscrx: waseem_: I want to have each db separated
[15:11:19] masscrx: mikecmpbll: but where to store passwords ? assume that I have two apps, 1."A- for billing services" where are all customers credentials and 2."shop" so app where customers will be authenticating and managing their stuff, and now each customer's shop instance needs username/password
[15:12:02] masscrx: for ActiveRecord
[15:12:26] masscrx: credentials for access to db
[15:14:04] masscrx: ah shit right, so simple
[15:15:56] masscrx: ok so create credentials in main db for customers, then create database and grant access with that credentials
[15:16:52] masscrx: "multi tenancy" is a key, thx
[15:17:56] masscrx: np I;ve needed some short talk to get some things more clear


[13:41:14] masscrx: has joined #RubyOnRails
[13:42:56] masscrx: I have main app with several engines, and from one of engines I would like to create new "service" so create new database from schema, for example for customer1 will be "c_1_db" database, for customer 2 "c_2_db" and so on... schema is the same for all databases, what way should I go ?
[13:44:14] masscrx: from engine level I will be managing these "services/databases"
[13:45:44] masscrx: so dynamically create config/database_suffix.yml or store all databases in one config file
[14:41:37] masscrx: are there any alternatives for storing password besides ENV and pass in file like database.yml ?


[05:21:33] masscrx: Remote host closed the connection


[00:10:16] masscrx: has joined #RubyOnRails


[16:50:05] masscrx: *.net *.split
[17:12:44] masscrx: has joined #RubyOnRails


[21:31:37] masscrx: Ping timeout: 252 seconds
[21:33:19] masscrx: has joined #RubyOnRails


[18:41:56] masscrx: Ping timeout: 246 seconds
[18:43:00] masscrx: has joined #RubyOnRails


[10:50:57] masscrx: Im trying to show object errors on view by @object.errors.full_messages.each do |msg| ... end
[10:51:05] masscrx: but on view is displayed: Account not found. ["Account not found."]
[10:51:12] masscrx: so, msg and array, how to show only msg ?
[10:52:30] masscrx: ok resolved


[10:27:08] masscrx: *.net *.split
[10:29:50] masscrx: has joined #RubyOnRails


[14:12:14] masscrx: can anybody help me with stron parameters for this request ?
[14:12:23] masscrx: I'm trying many solutions and none works
[14:26:29] masscrx: how to allow nested hash in strong params ? assume: customer => {profile_attributes: {}}
[14:28:42] masscrx: but then when it is passed as "profile_attributes"=>{} it is still unpermitted
[14:29:12] masscrx: workmad3: I;m passing nested hash instead array
[14:29:45] masscrx: so customer has_one :profile and then request: customer => {profile_attributes: {}}
[14:30:25] masscrx: workmad3: my strony params: params.require(:customer).permit(:id, :firstname, :lastname, :email, profiles_attributes: [:id, :saldo, :account_type, :_destroy, addresses_attributes: [:profile_id, :address_type, :street, :city, :postcode, :country_code]])
[14:31:17] masscrx: and result:
[14:31:18] masscrx: Parameters: {"utf8"=>"", "customer"=>{"firstname"=>"", "lastname"=>"", "email"=>"", "profile_attributes"=>{"account_type"=>"free"}}, "commit"=>"Create Customer"}
[14:31:21] masscrx: Unpermitted parameter: profile_attributes
[14:31:54] masscrx: where do you see profile"s" ?
[14:32:46] masscrx: ahh ok, now is error:
[14:32:48] masscrx: TypeError (no implicit conversion of Symbol into Integer):


[09:45:11] masscrx: has left #RubyOnRails: ()
[09:45:56] masscrx: has joined #RubyOnRails
[09:46:42] masscrx: can anybody help me with this rspec test ?


[10:30:59] masscrx: Im thinking how to resolve some case, I have application with two, maybe three roles in future - admin, manager, customer, for admin and manager will be one view (with some not big difference in read/write access) and for customer another view, so should I create two models? Admin and User ? or one model User with cancan roles ? now I have one User model with roles but what with controllers, after user sign in he is redirected to home#index by default,
[10:59:39] masscrx: arup_r: you can add callback like after_update :do_something and then add :do_something method with some action
[11:00:33] masscrx: sevenseacat: Im thinking how to resolve some case, I have application with two, maybe three roles in future - admin, manager, customer, for admin and manager will be one view (with some not big difference in read/write access) and for customer another view, so should I create two models? Admin and User ? or one model User with cancan roles ? now I have one User model with roles but what with controllers, after user sign in he is redirected to home#inde
[11:00:40] masscrx: arup_r: why ?
[11:01:31] masscrx: arup_r:


[11:32:47] masscrx: can anybody tell me what is going on ?
[11:32:54] masscrx: (devise gem)
[11:34:03] masscrx: ahhh ok thx
[11:34:47] masscrx: what was the method to convert error to more friendly format ?


[10:12:29] masscrx: can anybody help me with authentication ?
[10:17:18] masscrx: I have problem with understand authentication on rails and js framework
[10:17:42] masscrx: I know that js framework needs to send pass & email to rails and get response with token
[10:18:07] masscrx: but I dont know how to generate view with form, by rails or by js framework ?


[16:23:13] masscrx: I need some help with token based auth and front-end js framework, what I've read so far is that rails should response with 401 when user is not authenticated and then JS framework handle 401 request, and my problem is, that when accessing / path, 401 ise returned but backbonejs is not loaded
[16:23:46] masscrx: I cant catch the workflow what and when should be generated
[18:20:34] masscrx: I need some help with backbonejs and rails (token based auth), I dont understand exactly what and when should happen, assume that user is visiting root_path - then should see the login form, I have prepared rails so all unathenticated requests get 401 response, but then application#index is not served - backbonejs is not initialized
[18:21:03] masscrx: anybody can explain the app flow ?


[19:30:53] masscrx: I'm deploying auth in RoR, and my question is, what is a proper way for deploying auth with default admin account ? By signup ?
[19:31:22] masscrx: or create user in db with encoded password
[19:33:13] masscrx: doge__: I mean that when I have prepared User model, I need first account (admin( for managing others, so what is the proper way of creating that account ?
[19:34:33] masscrx: Signup action will be for normal users, but first account should be 'admin' and I'm not sure if should I create that account by signup or other way
[19:35:49] masscrx: doge__: this first 'default' user account will be managed by me ;]
[22:14:18] masscrx: Ping timeout: 272 seconds
[22:14:34] masscrx: has joined #RubyOnRails


[15:36:51] masscrx: batasrki: why not ?


[06:43:18] masscrx: *.net *.split
[06:43:25] masscrx: has joined #RubyOnRails


[12:24:09] masscrx: When exposing rails backend as json api only, what do you do with parameters which are sent to the backend but you dont need them ? In dev environment there is information "Unpermitted parameter: bau_addresses" which doesnt occur on production env but is annoying on dev, so you just ignore them or delete before sending to rails ?
[12:32:54] masscrx: Im getting by js framework some object assume 'invoice' in json format from rails, then when saving 'invoice' i would like to update another object as well so for example 'invoice_service' but onl with two attr, to make it clear objects look like that:
[12:33:42] masscrx: invoice(id:1. sum_total:150, unpaid_service: {service_id:1, status:'unpaid'})
[12:34:10] masscrx: and then when saving invoice i dont need invoice.unpaid_service["status"]
[12:34:18] masscrx: only service_id
[12:34:35] masscrx: I dont know if it is clear
[12:36:15] masscrx: I can delete unused attrs before sending to rails by some for() loop but I'm thinking about "cleaning" that stuff on the rails side
[12:36:32] masscrx: maybe it is wrong way
[12:38:07] masscrx: I have invoice, and I would like to connect some invoice with service on invoice_service join table, so I'm opening invoice, mark service as 'related' with that invoice, and when saving invoice I would like to save that connection in join table
[12:38:36] masscrx: so in invoice_services i have :service_id & :invoice_id
[12:40:37] masscrx: and so mikecmpbll request look like this:
[12:40:40] masscrx: Parameters: {"invoice"=>{"sum_total_netto"=>150, "invoice_items_attributes"=>[{"item_id"=>47, "quantity"=>1}], "invoice_services_attributes"=>[{"service_id"=>6, "status"=>"paid"}]}
[12:41:19] masscrx: service is created
[12:41:36] masscrx: im creating new invoice and 'connecting' with created before service
[12:41:53] masscrx: so we dont touch service (yet)
[12:42:12] masscrx: yeah I have that
[12:42:24] masscrx: but on dev env I have info about unpermitted params
[12:43:23] masscrx: ok you are right
[12:43:53] masscrx: I tought that kind of solutions as /littering/
[12:44:43] masscrx: aah no, ok I remember now where was the problem with permitting that params
[12:45:19] masscrx: when I permit :status, there was error that on model is not "status: field
[12:45:43] masscrx: uno momento
[12:46:31] masscrx: ActiveRecord::UnknownAttributeError (unknown attribute 'status' for InvoiceService.):
[12:46:37] masscrx: haha gracias senior
[12:47:55] masscrx: because I'm fetching invoice with nested array of unpaid services and I need them for view, but not when saving
[12:49:54] masscrx: 1.GET 'invoice' (user see invoice with unpaid services) 2.user connect as checkbox that service with invoice and click 'save' 3.and now we want to send to rails that service is connected with invoice
[12:51:13] masscrx: and that is a point, delete on JS framework side, or on backend side
[12:51:54] masscrx: ok, so in general backend should get only these params which actually needs?
[12:52:50] masscrx: Dont know, just thinking about another approaches
[12:53:32] masscrx: sometimes it looks weird if you have to 'clean' by loops object before sending
[12:55:36] masscrx: for 'view purposes' so for example we are fetching only one object with nested object contains only information for viewing, not for editing
[12:56:02] masscrx: so customer can see that his saldo is -400$ but dont wanna edit it
[12:57:34] masscrx: aah, yeah, so in angularjs you have something like Class.getAll('customers').then(function(result) { $scope.customers = result });
[12:57:38] masscrx: this is just example
[12:58:19] masscrx: amon777: whats going on ?
[12:59:14] masscrx: ok I'm going out have a nice day


[15:12:31] masscrx: Is there some way to check if ActionMailer object (mail) was sent properly ?
[15:17:12] masscrx: ok I'll check mailcatcher
[15:18:17] masscrx: ok but you are talking about "testing" but I mean something like mail(to:
[15:18:21] masscrx: mail.send?
[15:18:35] masscrx: so check in controller if mail was send
[15:19:48] masscrx: but there should me some callback, when Im trying in console sending mail without recipient, I have error: ArgumentError: An SMTP To address is required to send a message. Set the message smtp_envelope_to, to, cc, or bcc address.
[15:20:07] masscrx: so I think it is possible to check that message in controller
[15:24:33] masscrx: tubbo: I can validate all params before sent, but there could be situation when is problem with authentication with smtp server etc, so then we should know about that ;]
[15:25:41] masscrx: tubbo: so basicaly Mail:Message should return smtp code for example
[15:26:11] masscrx: taxen: sorry but Im playing with my issue for now ;]
[15:26:53] masscrx: taxen: .where return array
[15:27:14] masscrx: ok new terms for me