所以我有一個應用程序,有點像meetup.com,用戶可以創建事件,評論事件,通過GPS半徑搜索事件。但是,我想讓用戶點擊「參加」按鈕然後在events/show.html.erb頁面上顯示哪些用戶正在參加等...如何讓用戶參加活動?
我該怎麼做?
當前事件show.html.erb
<%= render 'shared/header' %>
<div class="container">
<div class="row">
<div class="span3">
<%= render 'sidebar' %>
</div>
<div class="span5">
<div class="new_event_form">
<div class="line1"><h4>Create event</h4></div>
<%= form_for current_user.events.new, remote: true do |f| %>
<h5>Event title:</h5>
<div><%= f.text_field :title, placeholder: "Event title", required: true, autocomplete: :off %></div>
<h5>Event description:</h5>
<div><%= f.text_area :description, placeholder: "Event description", required: true, autocomplete: :off %></div>
<h5>Event date:</h5>
<div><%= f.text_field :date %></div>
<h5>Event location:</h5>
<div><%= f.text_field :location, placeholder: "Event location", required: true, autocomplete: :off %></div>
<div>
<%= f.submit "Create event", class: 'btn btn-primary' %>
<%= link_to "Cancel", '#', class: 'btn cancel_event' %>
</div><br />
<% end %>
</div>
<div class="events_list">
<!-- look in events/event.hmlt.erb -->
<h4><%= @event.title %> at <%= @event.location %></h4>
<p><%= @event.description %></p>
<h5><i class="fa fa-calendar-o"></i> <%= @event.date.strftime("%A, %B %d, %Y") %></h5>
<h5><i class="fa fa-clock-o"></i> <%= @event.time %></h5>
<h5><i class="fa fa-map-marker"></i> <%= @event.location %></h5>
</div>
<div class="name"></div>
<%= form_for [@commentable, @comment], remote: true do |f| %>
...........and so on...
在先進的感謝!
什麼具體你有問題嗎? – Amadan
感謝Amadan,基本上 - 編寫代碼以允許用戶回覆,無法想到它應該是什麼以及它應該如何工作。 –
另外...爲什麼這標記爲'ruby-on-rails-4'和'ruby-on-rails-3'? – Amadan