has_and_belongs_to_many 관계가있는 사용자와 그룹이 포함 된 데이터베이스가 있습니다. 새 그룹이 추가되면 생성되지만 캐시를 지우거나 시크릿 창을 사용하여 로그인 할 때까지 그룹에 대한 사용자의 회원 자격이 전파되지 않습니다. 캐시가 지워질 때까지로드가 제대로되지 않는 것 같습니다. 이것은 최근에야 일어나기 시작했는데 그 이유를 알 수 없습니다! 어떤 도움이라도 대단히 감사하겠습니다. 모델에서레일 - 캐시를 지울 때까지 새 데이터로보기가 업데이트되지 않습니다.
:
class User < ActiveRecord::Base
has_many :services
has_many :recipes
has_and_belongs_to_many :groups
attr_accessible :recipes, :groups
end
class Group < ActiveRecord::Base
has_and_belongs_to_many :users
has_many :recipes
attr_accessible :description, :title, :recipe, :picture, :featured, :user_id
end
그룹 만들기 방법 :
def create
@user = User.find(current_user.id)
@group = Group.new(params[:group])
@group.user_id = @user.id
@user.groups << @group
redirect_to group_path(@group)
end
사용자의 그룹 구성원을 표시 - 캐시가 지워질 때까지이 업데이트되지 않습니다 :
<% @user.groups.each do |group| %>
<% if group %>
<p class="group-title"><a href="<%= group_path(group) %>"><%= group.title %></p>
<% @latestpic = Recipe.where("group_id = ?", group).limit(1).order("created_at DESC") %>
<% if @latestpic.exists? %>
<% @latestpic.each do |pic| %>
<%= image_tag(pic.picture.url(:medium)) %>
<% end %></a>
<% else %>
<%= image_tag "http://placehold.it/300x300" %>
<% end %>
<br></br>
<% end %>
<% end %>
@AdamEberlin - 난 레일 멍청 아. 내가 어떻게 확인할 수 있니? – Kim
RAILS 응용 프로그램을 제공하기 위해 RAILS 독립형 서버 또는 다른 서비스를 사용하고 있습니까? 그리고 어떤 운영 체제입니까? –
@AdamEberlin - 씬 웹 서버 (Chrome1.4.1 코드 명)를 사용하고 있습니다. 나는 Mac OS에있다. 이 문제는 Heroku에서 호스팅 될 때 로컬에서 발생합니다. – Kim