Original Post:
please help solve the problem.
There is a table users:
id :integer, autoincrement
name :string
gender_id :integer
There is a table genders:
id :integer, autoincrement
gender_name :string
model User:
class User < ActiveRecord::Base
belongs_to :gender
end
model Gender:
class Gender < ActiveRecord::Base
has_many :users
end
I need the gendername. I try to do so:
<% @users.each do |user| %>
<%= user.name %>
<%= user.gender_id %>
<% end %>
the result is output number, but I need to gendername
p.s.
so I tried:
<%= user.gender.gender_name %>
in this case receives the following error message:
undefined method `gender_name’ for nil:NilClass
Dear All,
I think that this post raises interesting issues regarding the gathering
of
a user’s gender. The developer is evidently not requiring user
indication
of gender, and has problems in the event of null. Perhaps that matter
is
optional. If so, why didn’t the developer provide an option for “User
Declines” as an example. But generally I think this matter is very
important. We exist in the 21st Century where a request for gender must
be
done with sensitivity. What is the convention in this matter?
Thanks,
Liz
On Jun 15, 2015, at 5:09 PM, Elizabeth McGurty [email protected]
wrote:
I think that this post raises interesting issues regarding the gathering of a
user’s gender. The developer is evidently not requiring user indication of
gender, and has problems in the event of null. Perhaps that matter is optional.
If so, why didn’t the developer provide an option for “User Declines” as an
example. But generally I think this matter is very important. We exist in the
21st Century where a request for gender must be done with sensitivity. What is
the convention in this matter?
Oh please, let’s not turn the simplest of bugs into a debate on gender
politics.
There is simply no single “convention” that will suffice for all
contexts.
–
Scott R.
[email protected]
http://www.elevated-dev.com/
https://www.linkedin.com/in/scottribe/
(303) 722-0567 voice
On 16 June 2015 at 00:09, Elizabeth McGurty [email protected] wrote:
id :integer, autoincrement
end
so I tried:
of gender, and has problems in the event of null. Perhaps that matter is
optional. If so, why didn’t the developer provide an option for “User
Declines” as an example.
I think you would have to ask the developer this. It is not a Rails
issue.
Perhaps in this case the developer allowed the field to be left empty,
marking it as an optional field.
But generally I think this matter is very
important. We exist in the 21st Century where a request for gender must be
done with sensitivity. What is the convention in this matter?
Rails does not have a convention in this any more than php does. It
is not an issue for the underlying framework or language, it is a
matter for the developer.
Colin
I think that it is a Rails issue. Scott writes: "Oh please, let’s not
turn
the simplest of bugs into a debate on gender politics. " The developer
was
not aware that gender name could be null. And we are all okay with
that… Seems to me a serious disconnect. This developer perhaps on a
very
large project where data requirements are not shared well. Whether is
it
gender or some other sensitive matter, it would be really cool to see
some
tie in data presentation.
We exist in the 21st Century where a request for gender must be done with
sensitivity
=(
On Tue, Jun 16, 2015 at 2:09 AM, Elizabeth McGurty [email protected]
On 16 June 2015 at 19:36, Elizabeth McGurty [email protected] wrote:
I think that it is a Rails issue. Scott writes: "Oh please, let’s not turn
the simplest of bugs into a debate on gender politics. " The developer was
not aware that gender name could be null. And we are all okay with that…
Seems to me a serious disconnect. This developer perhaps on a very large
project where data requirements are not shared well. Whether is it gender
or some other sensitive matter, it would be really cool to see some tie in
data presentation.
As I mentioned before it was not the gender_name that was nil, it was
that there was no gender object associated with the user. The
developer did not understand the error message was caused by this and
was apparently happy with the solution to only display the gender name
if there was an associated gender. Otherwise it seems he was
perfectly happy with no specified gender. I cannot understand why
this is causing you issues.
Colin
It’s political or social question rather than technical, and should be
asked on resources like reddit. or 4chan.
On Tue, Jun 16, 2015 at 10:26 PM, Vladimir Gordeev <