in my layout i wanna test if the user has a profile so when he clicks
profile my app know whether to present him with a show + link to edit the
exisiting profile, or just a form for new profile ~ thanks

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/0a78ce5d-1e7c-4f26-8c63-f9691689e191%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

  • Colin Law at Dec 27, 2015 at 8:51 pm

    On 27 December 2015 at 20:04, fugee ohu wrote:
    in my layout i wanna test if the user has a profile so when he clicks
    profile my app know whether to present him with a show + link to edit the
    exisiting profile, or just a form for new profile ~ thanks
    How do you access the user's profile? If it is @user.profile (or
    something similar) then @user.profile.nil? should do it.

    Colin
    --
    You received this message because you are subscribed to the Google Groups
    "Ruby on Rails: Talk" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to rubyonrails-talk+unsubscribe@googlegroups.com.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To view this discussion on the web visit
    https://groups.google.com/d/msgid/rubyonrails-talk/0a78ce5d-1e7c-4f26-8c63-f9691689e191%40googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAL%3D0gLvqi9yqcrLGFYzfZsy%2B_Z7aWwri9ju5NrswiserH8FG3w%40mail.gmail.com.
    For more options, visit https://groups.google.com/d/optout.
  • Fugee ohu at Dec 27, 2015 at 9:07 pm
    yikes, i dunno how @user got instantiated, i forgot to say i'm in a view, i
    dunno if i'm allowed to do this in a view or not: <% if
    Profile.find_by_user_id(current_user.id) %>
    On Sunday, December 27, 2015 at 3:51:45 PM UTC-5, Colin Law wrote:

    On 27 December 2015 at 20:04, fugee ohu <fuge...@gmail.com <javascript:>>
    wrote:
    in my layout i wanna test if the user has a profile so when he clicks
    profile my app know whether to present him with a show + link to edit the
    exisiting profile, or just a form for new profile ~ thanks
    How do you access the user's profile? If it is @user.profile (or
    something similar) then @user.profile.nil? should do it.

    Colin
    --
    You received this message because you are subscribed to the Google Groups
    "Ruby on Rails: Talk" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to rubyonrails-ta...@googlegroups.com <javascript:>.
    To post to this group, send email to rubyonra...@googlegroups.com
    <javascript:>.
    To view this discussion on the web visit
    https://groups.google.com/d/msgid/rubyonrails-talk/0a78ce5d-1e7c-4f26-8c63-f9691689e191%40googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/a9e1d87d-c329-427a-bb50-ae2fe2ae8d70%40googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Colin Law at Dec 27, 2015 at 9:15 pm

    On 27 December 2015 at 21:07, fugee ohu wrote:
    yikes, i dunno how @user got instantiated, i forgot to say i'm in a view, i
    dunno if i'm allowed to do this in a view or not: <% if
    Profile.find_by_user_id(current_user.id) %>
    You can do anything you like in a view, but what is wrong with
    <% if current_user.profile.nil? %>

    How many times do I have to ask you not to top post?

    Colin
    On Sunday, December 27, 2015 at 3:51:45 PM UTC-5, Colin Law wrote:
    On 27 December 2015 at 20:04, fugee ohu wrote:
    in my layout i wanna test if the user has a profile so when he clicks
    profile my app know whether to present him with a show + link to edit
    the
    exisiting profile, or just a form for new profile ~ thanks
    How do you access the user's profile? If it is @user.profile (or
    something similar) then @user.profile.nil? should do it.

    Colin
    --
    You received this message because you are subscribed to the Google
    Groups
    "Ruby on Rails: Talk" group.
    To unsubscribe from this group and stop receiving emails from it, send
    an
    email to rubyonrails-ta...@googlegroups.com.
    To post to this group, send email to rubyonra...@googlegroups.com.
    To view this discussion on the web visit

    https://groups.google.com/d/msgid/rubyonrails-talk/0a78ce5d-1e7c-4f26-8c63-f9691689e191%40googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
    --
    You received this message because you are subscribed to the Google Groups
    "Ruby on Rails: Talk" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to rubyonrails-talk+unsubscribe@googlegroups.com.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To view this discussion on the web visit
    https://groups.google.com/d/msgid/rubyonrails-talk/a9e1d87d-c329-427a-bb50-ae2fe2ae8d70%40googlegroups.com.

    For more options, visit https://groups.google.com/d/optout.
    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAL%3D0gLu9ZQOiarY%2BTErOQneLKuu4R-bpfDajhwWEh%3Dwh7P94KA%40mail.gmail.com.
    For more options, visit https://groups.google.com/d/optout.
  • Fugee ohu at Dec 27, 2015 at 9:24 pm

    On Sunday, December 27, 2015 at 4:15:57 PM UTC-5, Colin Law wrote:
    On 27 December 2015 at 21:07, fugee ohu <fuge...@gmail.com <javascript:>>
    wrote:
    yikes, i dunno how @user got instantiated, i forgot to say i'm in a view, i
    dunno if i'm allowed to do this in a view or not: <% if
    Profile.find_by_user_id(current_user.id) %>
    You can do anything you like in a view, but what is wrong with
    <% if current_user.profile.nil? %>

    How many times do I have to ask you not to top post?

    Colin
    On Sunday, December 27, 2015 at 3:51:45 PM UTC-5, Colin Law wrote:
    On 27 December 2015 at 20:04, fugee ohu wrote:
    in my layout i wanna test if the user has a profile so when he clicks
    profile my app know whether to present him with a show + link to edit
    the
    exisiting profile, or just a form for new profile ~ thanks
    How do you access the user's profile? If it is @user.profile (or
    something similar) then @user.profile.nil? should do it.

    Colin
    --
    You received this message because you are subscribed to the Google
    Groups
    "Ruby on Rails: Talk" group.
    To unsubscribe from this group and stop receiving emails from it,
    send
    an
    email to rubyonrails-ta...@googlegroups.com.
    To post to this group, send email to rubyonra...@googlegroups.com.
    To view this discussion on the web visit
    https://groups.google.com/d/msgid/rubyonrails-talk/0a78ce5d-1e7c-4f26-8c63-f9691689e191%40googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
    --
    You received this message because you are subscribed to the Google Groups
    "Ruby on Rails: Talk" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to rubyonrails-ta...@googlegroups.com <javascript:>.
    To post to this group, send email to rubyonra...@googlegroups.com
    <javascript:>.
    To view this discussion on the web visit
    https://groups.google.com/d/msgid/rubyonrails-talk/a9e1d87d-c329-427a-bb50-ae2fe2ae8d70%40googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
    Sorry Colin, It's the goolge default When you click reply the cursor
    flashes on a blank line with quoting below, that's why i always forget but
    I'll try to remember from now on Do I have to test for nil like that I'd
    rather use find or find_by more absolutely ~ thanks (merry christmas)

    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/72ab4192-6c0d-419e-8efc-22392ef797f4%40googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Colin Law at Dec 27, 2015 at 9:35 pm

    On 27 December 2015 at 21:24, fugee ohu wrote:
    On Sunday, December 27, 2015 at 4:15:57 PM UTC-5, Colin Law wrote:
    On 27 December 2015 at 21:07, fugee ohu wrote:
    yikes, i dunno how @user got instantiated, i forgot to say i'm in a
    view, i
    dunno if i'm allowed to do this in a view or not: <% if
    Profile.find_by_user_id(current_user.id) %>
    You can do anything you like in a view, but what is wrong with
    <% if current_user.profile.nil? %>

    How many times do I have to ask you not to top post?
    Sorry Colin, It's the goolge default When you click reply the cursor flashes
    on a blank line with quoting below, that's why i always forget but I'll try
    to remember from now on Do I have to test for nil like that I'd rather use
    find or find_by more absolutely ~ thanks (merry christmas)
    It is not a matter of how you test for nil, it is a matter of how you
    access the profile. You suggest using
    Profile.find_by_user_id(current_user.id) but you can just do
    current_user.profile. It is the same thing but much easier to
    understand. You can test for nil any way you like.

    Colin

    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAL%3D0gLudCVq2-8kLnbQUUtugJN%3D4fpk7rzccino2NSwhnBXfgA%40mail.gmail.com.
    For more options, visit https://groups.google.com/d/optout.
  • Fugee ohu at Dec 27, 2015 at 9:53 pm

    On Sunday, December 27, 2015 at 4:35:37 PM UTC-5, Colin Law wrote:
    On 27 December 2015 at 21:24, fugee ohu <fuge...@gmail.com <javascript:>>
    wrote:
    On Sunday, December 27, 2015 at 4:15:57 PM UTC-5, Colin Law wrote:
    On 27 December 2015 at 21:07, fugee ohu wrote:
    yikes, i dunno how @user got instantiated, i forgot to say i'm in a
    view, i
    dunno if i'm allowed to do this in a view or not: <% if
    Profile.find_by_user_id(current_user.id) %>
    You can do anything you like in a view, but what is wrong with
    <% if current_user.profile.nil? %>

    How many times do I have to ask you not to top post?
    Sorry Colin, It's the goolge default When you click reply the cursor flashes
    on a blank line with quoting below, that's why i always forget but I'll try
    to remember from now on Do I have to test for nil like that I'd rather use
    find or find_by more absolutely ~ thanks (merry christmas)
    It is not a matter of how you test for nil, it is a matter of how you
    access the profile. You suggest using
    Profile.find_by_user_id(current_user.id) but you can just do
    current_user.profile. It is the same thing but much easier to
    understand. You can test for nil any way you like.

    Colin
      Thanks colin, happy holidays again ha ha Ok so then i'm using `if
    current_user.profile?` but the snippet is causing the error
    application.html.erb:59: syntax error, unexpected keyword_ensure, expecting
    end-of-input, even though application.html.erb is only 57 lines

        <% user_signed_in? %>
        <% if current_user.profile? %>
         <%= "profile found" %>
        <% else %>
         <%= "profile not found" %>
        <% end %>
        <div class="dropdown">
         <button class="btn btn-primary dropdown-toggle" type="button"
    data-toggle="dropdown"><%= current_user.email %></button>
         <ul class="dropdown-menu"><span class="caret"></span>
           <li><%= link_to('Profile', user_profile_path ) %></li>
           <li><a href="#">Account</a></li>
           <li><a href="#">Messages</a></li>
           <li><%= link_to('Sign out', destroy_user_session_path, method:
    :delete) %></li>
         </ul>
       </div>
       <% else %>
        <div align=right>
         <%= link_to('User sign in', new_user_session_path) %>
        </div>
       <% end %>

    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/7e6d5ed8-06f4-4b77-89bb-f571a5ca3efd%40googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Colin Law at Dec 27, 2015 at 10:01 pm

    On 27 December 2015 at 21:53, fugee ohu wrote:
    On Sunday, December 27, 2015 at 4:35:37 PM UTC-5, Colin Law wrote:
    On 27 December 2015 at 21:24, fugee ohu wrote:
    On Sunday, December 27, 2015 at 4:15:57 PM UTC-5, Colin Law wrote:
    On 27 December 2015 at 21:07, fugee ohu wrote:
    yikes, i dunno how @user got instantiated, i forgot to say i'm in a
    view, i
    dunno if i'm allowed to do this in a view or not: <% if
    Profile.find_by_user_id(current_user.id) %>
    You can do anything you like in a view, but what is wrong with
    <% if current_user.profile.nil? %>

    How many times do I have to ask you not to top post?
    Sorry Colin, It's the goolge default When you click reply the cursor
    flashes
    on a blank line with quoting below, that's why i always forget but I'll
    try
    to remember from now on Do I have to test for nil like that I'd rather
    use
    find or find_by more absolutely ~ thanks (merry christmas)
    It is not a matter of how you test for nil, it is a matter of how you
    access the profile. You suggest using
    Profile.find_by_user_id(current_user.id) but you can just do
    current_user.profile. It is the same thing but much easier to
    understand. You can test for nil any way you like.

    Colin

    Thanks colin, happy holidays again ha ha Ok so then i'm using `if
    current_user.profile?` but the snippet is causing the error
    application.html.erb:59: syntax error, unexpected keyword_ensure, expecting
    end-of-input, even though application.html.erb is only 57 lines

    <% user_signed_in? %>
    <% if current_user.profile? %>
    <%= "profile found" %>
    <% else %>
    <%= "profile not found" %>
    <% end %>
    <div class="dropdown">
    <button class="btn btn-primary dropdown-toggle" type="button"
    data-toggle="dropdown"><%= current_user.email %></button>
    <ul class="dropdown-menu"><span class="caret"></span>
    <li><%= link_to('Profile', user_profile_path ) %></li>
    <li><a href="#">Account</a></li>
    <li><a href="#">Messages</a></li>
    <li><%= link_to('Sign out', destroy_user_session_path, method:
    :delete) %></li>
    </ul>
    </div>
    <% else %>
    <div align=right>
    <%= link_to('User sign in', new_user_session_path) %>
    </div>
    <% end %>
    There is no matching 'if' for this 'end'.

    Colin

    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAL%3D0gLsUZJGbbpH3MUZ1N%3DHGUjFw6sL%3DjTXPwSqzNp_0-zEfkw%40mail.gmail.com.
    For more options, visit https://groups.google.com/d/optout.
  • Fugee ohu at Dec 27, 2015 at 10:38 pm
    what does this mean without the if <% user_signed_in? %>
    On Sunday, December 27, 2015 at 5:01:54 PM UTC-5, Colin Law wrote:

    On 27 December 2015 at 21:53, fugee ohu <fuge...@gmail.com <javascript:>>
    wrote:
    On Sunday, December 27, 2015 at 4:35:37 PM UTC-5, Colin Law wrote:
    On 27 December 2015 at 21:24, fugee ohu wrote:
    On Sunday, December 27, 2015 at 4:15:57 PM UTC-5, Colin Law wrote:
    On 27 December 2015 at 21:07, fugee ohu wrote:
    yikes, i dunno how @user got instantiated, i forgot to say i'm in
    a
    view, i
    dunno if i'm allowed to do this in a view or not: <% if
    Profile.find_by_user_id(current_user.id) %>
    You can do anything you like in a view, but what is wrong with
    <% if current_user.profile.nil? %>

    How many times do I have to ask you not to top post?
    Sorry Colin, It's the goolge default When you click reply the cursor
    flashes
    on a blank line with quoting below, that's why i always forget but
    I'll
    try
    to remember from now on Do I have to test for nil like that I'd
    rather
    use
    find or find_by more absolutely ~ thanks (merry christmas)
    It is not a matter of how you test for nil, it is a matter of how you
    access the profile. You suggest using
    Profile.find_by_user_id(current_user.id) but you can just do
    current_user.profile. It is the same thing but much easier to
    understand. You can test for nil any way you like.

    Colin

    Thanks colin, happy holidays again ha ha Ok so then i'm using `if
    current_user.profile?` but the snippet is causing the error
    application.html.erb:59: syntax error, unexpected keyword_ensure, expecting
    end-of-input, even though application.html.erb is only 57 lines

    <% user_signed_in? %>
    <% if current_user.profile? %>
    <%= "profile found" %>
    <% else %>
    <%= "profile not found" %>
    <% end %>
    <div class="dropdown">
    <button class="btn btn-primary dropdown-toggle" type="button"
    data-toggle="dropdown"><%= current_user.email %></button>
    <ul class="dropdown-menu"><span class="caret"></span>
    <li><%= link_to('Profile', user_profile_path ) %></li>
    <li><a href="#">Account</a></li>
    <li><a href="#">Messages</a></li>
    <li><%= link_to('Sign out', destroy_user_session_path, method:
    :delete) %></li>
    </ul>
    </div>
    <% else %>
    <div align=right>
    <%= link_to('User sign in', new_user_session_path) %>
    </div>
    <% end %>
    There is no matching 'if' for this 'end'.

    Colin
    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/5977573e-e179-457d-96db-2c7d31f09f41%40googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Colin Law at Dec 27, 2015 at 10:44 pm

    On 27 December 2015 at 22:38, fugee ohu wrote:
    what does this mean without the if <% user_signed_in? %>
    It is just a statement that evaluates to true or false and does
    nothing with the result.

    Colin
    On Sunday, December 27, 2015 at 5:01:54 PM UTC-5, Colin Law wrote:
    On 27 December 2015 at 21:53, fugee ohu wrote:
    On Sunday, December 27, 2015 at 4:35:37 PM UTC-5, Colin Law wrote:
    On 27 December 2015 at 21:24, fugee ohu wrote:
    On Sunday, December 27, 2015 at 4:15:57 PM UTC-5, Colin Law wrote:
    On 27 December 2015 at 21:07, fugee ohu wrote:
    yikes, i dunno how @user got instantiated, i forgot to say i'm in
    a
    view, i
    dunno if i'm allowed to do this in a view or not: <% if
    Profile.find_by_user_id(current_user.id) %>
    You can do anything you like in a view, but what is wrong with
    <% if current_user.profile.nil? %>

    How many times do I have to ask you not to top post?
    Sorry Colin, It's the goolge default When you click reply the cursor
    flashes
    on a blank line with quoting below, that's why i always forget but
    I'll
    try
    to remember from now on Do I have to test for nil like that I'd
    rather
    use
    find or find_by more absolutely ~ thanks (merry christmas)
    It is not a matter of how you test for nil, it is a matter of how you
    access the profile. You suggest using
    Profile.find_by_user_id(current_user.id) but you can just do
    current_user.profile. It is the same thing but much easier to
    understand. You can test for nil any way you like.

    Colin

    Thanks colin, happy holidays again ha ha Ok so then i'm using `if
    current_user.profile?` but the snippet is causing the error
    application.html.erb:59: syntax error, unexpected keyword_ensure,
    expecting
    end-of-input, even though application.html.erb is only 57 lines

    <% user_signed_in? %>
    <% if current_user.profile? %>
    <%= "profile found" %>
    <% else %>
    <%= "profile not found" %>
    <% end %>
    <div class="dropdown">
    <button class="btn btn-primary dropdown-toggle" type="button"
    data-toggle="dropdown"><%= current_user.email %></button>
    <ul class="dropdown-menu"><span class="caret"></span>
    <li><%= link_to('Profile', user_profile_path ) %></li>
    <li><a href="#">Account</a></li>
    <li><a href="#">Messages</a></li>
    <li><%= link_to('Sign out', destroy_user_session_path, method:
    :delete) %></li>
    </ul>
    </div>
    <% else %>
    <div align=right>
    <%= link_to('User sign in', new_user_session_path) %>
    </div>
    <% end %>
    There is no matching 'if' for this 'end'.

    Colin
    --
    You received this message because you are subscribed to the Google Groups
    "Ruby on Rails: Talk" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to rubyonrails-talk+unsubscribe@googlegroups.com.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To view this discussion on the web visit
    https://groups.google.com/d/msgid/rubyonrails-talk/5977573e-e179-457d-96db-2c7d31f09f41%40googlegroups.com.

    For more options, visit https://groups.google.com/d/optout.
    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAL%3D0gLseWht7ow6gr7gT7n2%3D9r%2BK%3DQBASNkr3sC6vxsU-1aM1g%40mail.gmail.com.
    For more options, visit https://groups.google.com/d/optout.
  • Fugee ohu at Dec 27, 2015 at 10:59 pm
    thanks
    On Sunday, December 27, 2015 at 5:44:51 PM UTC-5, Colin Law wrote:

    On 27 December 2015 at 22:38, fugee ohu <fuge...@gmail.com <javascript:>>
    wrote:
    what does this mean without the if <% user_signed_in? %>
    It is just a statement that evaluates to true or false and does
    nothing with the result.

    Colin
    On Sunday, December 27, 2015 at 5:01:54 PM UTC-5, Colin Law wrote:
    On 27 December 2015 at 21:53, fugee ohu wrote:
    On Sunday, December 27, 2015 at 4:35:37 PM UTC-5, Colin Law wrote:
    On 27 December 2015 at 21:24, fugee ohu wrote:
    On Sunday, December 27, 2015 at 4:15:57 PM UTC-5, Colin Law wrote:
    On 27 December 2015 at 21:07, fugee ohu wrote:
    yikes, i dunno how @user got instantiated, i forgot to say i'm
    in
    a
    view, i
    dunno if i'm allowed to do this in a view or not: <% if
    Profile.find_by_user_id(current_user.id) %>
    You can do anything you like in a view, but what is wrong with
    <% if current_user.profile.nil? %>

    How many times do I have to ask you not to top post?
    Sorry Colin, It's the goolge default When you click reply the
    cursor
    flashes
    on a blank line with quoting below, that's why i always forget but
    I'll
    try
    to remember from now on Do I have to test for nil like that I'd
    rather
    use
    find or find_by more absolutely ~ thanks (merry christmas)
    It is not a matter of how you test for nil, it is a matter of how
    you
    access the profile. You suggest using
    Profile.find_by_user_id(current_user.id) but you can just do
    current_user.profile. It is the same thing but much easier to
    understand. You can test for nil any way you like.

    Colin

    Thanks colin, happy holidays again ha ha Ok so then i'm using `if
    current_user.profile?` but the snippet is causing the error
    application.html.erb:59: syntax error, unexpected keyword_ensure,
    expecting
    end-of-input, even though application.html.erb is only 57 lines

    <% user_signed_in? %>
    <% if current_user.profile? %>
    <%= "profile found" %>
    <% else %>
    <%= "profile not found" %>
    <% end %>
    <div class="dropdown">
    <button class="btn btn-primary dropdown-toggle" type="button"
    data-toggle="dropdown"><%= current_user.email %></button>
    <ul class="dropdown-menu"><span class="caret"></span>
    <li><%= link_to('Profile', user_profile_path ) %></li>
    <li><a href="#">Account</a></li>
    <li><a href="#">Messages</a></li>
    <li><%= link_to('Sign out', destroy_user_session_path, method:
    :delete) %></li>
    </ul>
    </div>
    <% else %>
    <div align=right>
    <%= link_to('User sign in', new_user_session_path) %>
    </div>
    <% end %>
    There is no matching 'if' for this 'end'.

    Colin
    --
    You received this message because you are subscribed to the Google Groups
    "Ruby on Rails: Talk" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to rubyonrails-ta...@googlegroups.com <javascript:>.
    To post to this group, send email to rubyonra...@googlegroups.com
    <javascript:>.
    To view this discussion on the web visit
    https://groups.google.com/d/msgid/rubyonrails-talk/5977573e-e179-457d-96db-2c7d31f09f41%40googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/43154162-4752-4d9b-a54f-844b6d44ebb7%40googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouprubyonrails-talk @
categoriesrubyonrails
postedDec 27, '15 at 8:04p
activeDec 27, '15 at 10:59p
posts11
users2
websiterubyonrails.org
irc#RubyOnRails

2 users in discussion

Fugee ohu: 6 posts Colin Law: 5 posts

People

Translate

site design / logo © 2021 Grokbase