last day (15 days later) » 

9:03 PM
hey buddy
 
hey do you want to join teamviewer?
 
sure let me just get it again
 
ID = 282 979 161
pwd = 2930
 
btw are you in spain?
 
no
I'm in Peru
 
9:06 PM
amazing!
 
ok 1 min
let me test it
 
man
sorry
can you wait 30 min
 
need to do something important
 
9:08 PM
sure
I'll stay in chat, just let me know when you're back
 
psw = 1589
sorry
i had some problems
 
np
interesting
this is not a stackoverflow error, though - is this different?
 
Did you see?
 
after post params
ys showing SELECT
 
9:14 PM
its not stack level deep error, though?
 
SELECT user_ejecutives.* FROM user_ejecutives WHERE user_ejecutives.id IN (4, 10)
 
is there another error, or is it?
 
is similar
because
if I use your code will work
check it out
but only for def new
 
show ejecutive.rb
 
when i use your line
works
has_and_belongs_to_many :user_ejecutives, class_name: "User", join_table: "user_ejecutives", foreign_key: :user_id, association_foreign_key: :ejecutive_id
 
9:17 PM
btw I live near where Wayne Rooney was born, liverpool
 
Oh my god
Really? love manchester united
 
yep live near manchester
its very rainy ;)
 
awesome!
ok
 
can I see ejecutive.rb?
 
will show.html.erb
 
9:18 PM
ok
what is in ejecutive table?
the has_and_belongs_to_many is "self referential" (it looks in User model)
when you hasmany through, you load ejecutive table
what is in it?
 
Ejecutive table is the table
id name
here
 
can you show me in PHPMyadmin?
 
how is it different to user table?
 
now look at this
 
9:24 PM
i think the problem is to do with your ejecutives table/model
with has_and_belongs_to_many, you were referencing the users table
with has_many :through, you're referencing ejecutives table
they look like they contain the same data to me
 
Now I investigating i did this
wait a second
used nested params
 
Did you see?
 
yes
can you show me user.rb again?
 
Is working correctly i think
 
9:28 PM
ok
let's try something
in user_ejecutive.rb
let's make it belongs_to :ejecutive, class_name: "User"
and then try has_many :through again
 
ok should i remove nested form?
or lets try your way?
 
remove nested form
we dont need it
 
ok sir
 
let's try making the user_ejecutive self referential
it might not work; I want to undersatnd why it's making your error and stack level error
 
keep this ?
has_and_belongs_to_many :user_ejecutives, class_name: "User", join_table: "user_ejecutives", foreign_key: :user_id, association_foreign_key: :ejecutive_id
 
9:34 PM
no, comment out
in user
we should have
has_many user_ejecutives
has_many ejecutives, through: :user_ejecutives
then in user_ejecutive.rb
belongs_to :user
belongs_to :ejecutive, class_name: "User"
 
done
trying demo
 
ok
lol
okay I think the problem might be that we're passing user_ejecutive_ids
it should be ejecutive_ids
try demo again
 
man
will be out for 10 min
 
np
the core pattern works
it's just small tweak with ejecutive & user models
I will stay on chat
 
10:17 PM
u back yet?
 
10:44 PM
yes
im here
now is not showing errors
but is not showing data
= (
 
hey
is the data in the db okay?
 
yes
 
okay
temviewer again?
 
do you want to join
okey
yes now i have time
 
sure
i think i have maybe 30 minutes
but i might get cut off
 
10:56 PM
yes
thanks
 
if I go offline, it's because the Internet got turned off
 
282 979 161
 
so don't think I'm rude :D
 
6264
np
when I will have a OCR APP I will give u the project for free
check it out
 
thanks bud!
tv frozen
its back now
so data is in db
 
10:58 PM
did you see
 
where does it not show?
yep I saw thank you
 
is saving the params
now the problem is here
in show.html.erb
 
<% obj_user.ejecutives.each
it should be
okay
the issue here is that we need a str_name_complete method in your User model
btw you don't need to use return in ruby; it automatically returns the last line in a method
 
oh i see
lastname2 is blank
so for that reason is showing error
 
possibly
the main reason is that we have made belongs_to :ejecutive, class_name: "User"
which means that each ejecutive uses the User mdoel
since you call str_name_complete (which exists in Ejecutive class), you'll either have to remove class_name: "User" reference, or move str_name_complete from Ejecutive to User
 
11:02 PM
oh
its working
 
yes
read my last message, it will explain
 
but is not recognizing str_name_complete
to remove class_name: "User
ok doing
remove where?
on Ejecutive.rb
 
on user_ejectuve.rb
 
or UserEjecutive.rb
 
ejecutive should ahve
has_many :user_ejecutives
has_many :users, through: :user_ejecutives
 
11:05 PM
done
ejecutive should ahve
has_many :user_ejecutives
has_many :users, through: :user_ejecutives
really?
 
yes
what does it have now
exactly the same as you have already, its oaky
i thought you had belongs_to in there
 
class UserEjecutive < ActiveRecord::Base
belongs_to :user
belongs_to :ejecutive
 
class Ejecutive < ActiveRecord::Base
has_many :user_ejecutives
has_many :users, through: :user_ejecutives
 
this may fuck up the ids in your user_ejectuvive table
yes that is good
 
11:07 PM
but I need to keep the id
 
sorry
i meant
the ejecutive_id
 
ok trying
 
since you're using two sets of data, the ejecutive_id will be referenecing the ejecutives table now
so don't be surprised if it says "cannot find ejecutive with id x"
now check your view
 
lol finally the same code
that i had
 
yes but different modes
models*
different data sets
which is an antipattern
 
11:10 PM
what is antipattern
 
its like fixing a aeroplane wing with tape
 
do you mean will be hacked by sql inyection?
 
An anti-pattern (or antipattern) is a common response to a recurring problem that is usually ineffective and risks being highly counterproductive. The term, coined in 1995 by Andrew Koenig, was inspired by a book, Design Patterns, which highlights a number of design patterns in software development that its authors considered to be highly reliable and effective. The term was popularized three years later by the book AntiPatterns, which extended its use beyond the field of software design and into general social interaction and may be used informally to refer to any commonly reinvented but b...
no
it means your app has design flaw
you're trying to reference users as ejecutives
I think you should "self reference" -- IE belongs_to :ejecutive, class_name: "User"
this makes each ejecutive_id reference a User -- keeping the data all in the users table
right now, you can only reference ejecutives which exist in the ejecutives table, meaning you have to copy your data from users
you could have easily fixed your show view error by putting the def str_name_complete into the User model
 
i have the same code
#User.rb
has_many :ejecutives, :through => :user_ejecutives
has_many :user_ejecutives

#Ejecutive.rb
has_many :user_ejecutives
has_many :users, :through => :user_ejecutives

#UserEjecutive.rb
belongs_to :user
belongs_to :ejecutive
 
lol ok
well as long as it works, and you're happy
that's all that counts
 
11:14 PM
you only modified

private
def user_params
params.require(:user).permit(:name, ejecutive_ids: [])
end
 
lol
and neil armstrong only went for a stroll on the moon
it's the effort which counts
 
lol
but explain me before you go
 
because with has_many :through
 
why user_ejecutive_ids wasnt' working
 
the "end" objects are defined as the "through" association
with HABTM, you call user_ejecutives and the actual objects are available
with hmt, referencing the join model only pulls the join data, not the actual object data you need
so we had to change the objects we were referencing
 
11:17 PM
params.require(:user).permit(:name, user_ejecutive_ids: [])
was doing SELECT after record the data
 
yes, because it was trying to find the user_ejecutive, which was not valid as we were passing incorrect ids
 
i know it is confusing
 
now i got it
 
you should think about it and it will be clearer
 
11:18 PM
thought just need a "NAME"
 
nooo
 
params.require(:user).permit(:name, parameter_example_ids: [])
<%= f.collection_select(:parameter_example_ids, @list_ejecutives, :id, :lastname1, {:prompt => false}, {:multiple => true, class: "input-sm validate[required]" }) %>
 
ye
dependingo n the associations, this should be okay
 
so if i neeed to pass for example this:
params.require(:user).permit(:name, manager_ids: [])
<%= f.collection_select(:manager_ids, @list_ejecutives, :id, :lastname1, {:prompt => false}, {:multiple => true, class: "input-sm validate[required]" }) %>
 
only if you have has_and_belongs_to_many :managers
or has_many :managers, through: :user_managers etc
 
11:22 PM
#User.rb
has_many :ejecutives, :through => :user_ejecutives
has_many :user_ejecutives

#Ejecutive.rb
has_many :user_ejecutives
has_many :users, :through => :user_ejecutives

#UserEjecutive.rb
belongs_to :user
belongs_to :ejecutive
belongs_to :manager
 
#user.rb
has_many :managers, through: :user_ejecutives
 
#manager.rb
has_many :ejecutives, :through => :user_ejecutives
has_many :user_ejecutives
 
then you'd be able to use manager_ids for user
 
ok ok
Got it and learned
 
11:24 PM
how did you learn?
 
thanks for the experience, it's eye-opening to see how others work :)
 
all is on the api?
 
api?
 
you learn it as you grow
 
11:26 PM
lol
but good advice
well thank you sir
 
thanks!!
 
my email is carlosmoralesl772@gmail.com
when i got the ocr app will send u as gift
 
looking good!!
mine is peckrich@gmail.com - I'll email you and we can talk if you like
I g2g now, have a great day/evening!
 

last day (15 days later) »