我第一次問這個網站的問題,希望你能幫我解決我的'問題'。 :-)Rails 3.2奇怪的意見
其實,這不是真正在發展中的問題,但在生產...
這裏是我的問題:
我與Rails的3.2.11和2.1.7紅寶石工作。爲此,我使用RubyMine。 從一開始,當我在散列中推送一些數據時,該記錄也出現在集合的用戶實例中。
我在我的配置中搜索,在我的development.rb中,initializers,...但我不知道它在哪裏! :-(
因爲我沒有對本網站的任何名譽,我不能告訴你它是什麼,所以我會以另一種方式解釋它。
我我的用戶「測試1」增加通過視圖通過點擊 '登錄' 比賽 我的觀點(我用Haml的):
應用程序/視圖/邀請賽/ show.html.haml
%p#notice= notice
%p
%b Name:
= @tournament.name
%p
%b Place:
= @tournament.place
= @tournament.to_coordinates
%p
= image_tag "http://maps.google.com/maps/api/staticmap?size=450x300&sensor=false&zoom=16&markers=#{@tournament.latitude}%2C#{@tournament.longitude}"
%p
%b Nb players max:
= @tournament.nb_players_max
- if can? :update, @tournament
= link_to 'Add Match', new_match_path(@tournament.id)
|
= link_to 'Add Games', show_games_path(@tournament.id)
|
= link_to 'Edit', edit_tournament_path(@tournament)
|
= link_to 'Back', tournaments_path
- if @tournament.users.include?(@current_user)
%p
you\'re already signed in for this tournament
- else
= form_for @tournament, url: add_player_path, method: :post do |f|
= f.hidden_field 'tournament_id', :value => @tournament.id
= f.submit 'Sign in'
= link_to 'Seed players', seed_players_path(@tournament.id), method: :post
- if @tournament.users.any?
%ul.list-group
= @tournament.users.each do |player|
%li.list-group-item
= player.pseudo
- else
%p
No players for this tournament.
- if @tournament.games.any?
= @tournament.games.each do |game|
%h2
= game.title
= link_to 'Sign in all players'
- else
%p
No games for this tournament. A new game will be added rapidly.
點擊在登錄按鈕上,用戶被正確添加到@t中ournament.users。但是,這也出現在正下方的觀點:
- if @tournament.users.any?
%ul.list-group
= @tournament.users.each do |player|
%li.list-group-item
= player.pseudo
- else
%p
No players for this tournament.
[#<User id: 29, country: "BE", nb_victory: nil, nb_defeat: nil, total_points: nil, created_at: "2016-02-16 14:20:36", updated_at: "2016-02-18 10:07:49", first_name: "T", last_name: "T", pseudo: "Test1", email: "[email protected]", encrypted_password: "$2a$10$WRHkX0mN0t1GAEYg8CQPJeVHBg0bVzBmDxpHKtU.g23A...", reset_password_token: nil, reset_password_sent_at: nil, remember_created_at: nil, sign_in_count: 3, current_sign_in_at: "2016-02-18 10:07:49", last_sign_in_at: "2016-02-17 09:31:06", current_sign_in_ip: "127.0.0.1", last_sign_in_ip: "127.0.0.1", confirmation_token: "Q2rJ8aWYPmttd9XRjKgX", confirmed_at: nil, confirmation_sent_at: "2016-02-16 14:20:36", unconfirmed_email: nil, avatar: "chat.png", provider: nil, uid: nil, role: "player">]
在HTML代碼中,我可以看到這一點:
<ul class="list-group">
<li class="list-group-item"> Test1 </li>
[#<User id: 29, country: "BE", nb_victory: nil, nb_defeat: nil, total_points: nil, created_at: "2016-02-16 14:20:36", updated_at: "2016-02-18 10:07:49", first_name: "T", last_name: "T", pseudo: "Test1", email: "[email protected]", encrypted_password: "$2a$10$WRHkX0mN0t1GAEYg8CQPJeVHBg0bVzBmDxpHKtU.g23A...", reset_password_token: nil, reset_password_sent_at: nil, remember_created_at: nil, sign_in_count: 3, current_sign_in_at: "2016-02-18 10:07:49", last_sign_in_at: "2016-02-17 09:31:06", current_sign_in_ip: "127.0.0.1", last_sign_in_ip: "127.0.0.1", confirmation_token: "Q2rJ8aWYPmttd9XRjKgX", confirmed_at: nil, confirmation_sent_at: "2016-02-16 14:20:36", unconfirmed_email: nil, avatar: "chat.png", provider: nil, uid: nil, role: "player">]
</ul>
這有什麼錯呢?這似乎是一個配置問題。
你可能不正確地使用'< %='當你打算爲每個''方法調用使用'<%'時,但是不可能告訴,因爲你沒有提供任何導致問題的實際代碼:(而且這裏沒有什麼像一個散列,一個集合中的用戶實例 –
我要用你的意見編輯我的文章:-) –
它已更新:) –