ruby on rails - Find out if table has ever had records in it, even deleted -


i want show view users if notes column record doesn't have entry previously. i.e ideally first time users.

if user deletes note after creating (i.e 0 entries) want show same thing if there records in table.

for can't counts like

@notes_list = current_user.notes 

and in view

<% if @notes_list.count == 0 %>       <%# view 1 %> <% else %>       <%# view 2 %> <% end %> 

so can please me out on or there other better way if check?

you can add new column user model named note_created boolean default false value. whenever new user creates field remain false. if user creates post you'll make true rest of time. if user deletes notes field remain true. , can swap views based on field.

it may lame solution. don't have better solution right now. :d

def create   @new_note = note.new(notes_params)   if @new_note.save     unless @new_note.user.note_created       @new_note.user.note_created = true        @new_note.user.save     end    // rest of code   end  end 

Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -