Wpis z mikrobloga

#ror #rails

mam o to takie pliki z kodem:

(tutaj w paste bin http://pastebin.com/3ZdTYijd )

class AnswersController < ApplicationController

..# GET /answers

..# GET /answers.json

..beforefilter :gettweet

..def gettweet

....@tweet = Tweet.find(params[:tweet
id])

..end

..def index

....@answers = @tweet.answers

..respond_to do |format|

...format.html # index.html.erb

...format.json { render json: @answers }

..end

..end

.

.

.

i drugi

Listing answers
===============

|
Status |
|
|
|

<% @answers.each do |answer| %>
|
<%= answer.body %> |
<%= linkto 'Show', answer %></td>_
<td><%= link
to 'Edit', edittweetanswerpath(@tweet, answer) %></td>
<td><%= link
to 'Destroy', [@tweet, answer], method: :delete, data: { confirm: 'Are you sure?' } %> |

<% end %>

<%= linkto 'New Answer', newtweetanswerpath(@tweet) %>

no i wyrzuca mi taki blad: (jak temu zapobiec i to naprawic?):

ActiveRecord::StatementInvalid in Answers#index

Showing /Users/porque/Documents/rails/anonimsblog/app/views/answers/index.html.erb where line #11 raised:

PG::Error: ERROR: column answers.tweetid does not exist
_
LINE 1: SELECT "answers".* FROM "answers" WHERE "answers"."tweet_id...

^

: SELECT "answers".* FROM "answers" WHERE "answers"."tweetid" = 7

Extracted source (around line #11):

8: |

9:

10:

11: <% @answers.each do |answer| %>

12: |

13: <%= answer.body %> |

14: <%= link
to 'Show', answer %> |

Rails.root: /Users/porque/Documents/rails/anonimsblog

Application Trace | Framework Trace | Full Trace

app/views/answers/index.html.erb:11:in

_app_views_answers_index_html_erb___978901395340277426_70154436314900'

app/controllers/answers_controller.rb:14:in

index'

Request

Parameters:

{"tweetid"=>"7"}

Show session dump

csrftoken: "JDTFe/lv/VegLsa++unVo53zbQzghDxn7soD3acniVM="

sessionid: "01e1755db52b0e08f53413bc373ca3c4"

Show env dump

GATEWAY
INTERFACE: "CGI/1.1"

HTTPACCEPT: "text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8"

HTTP
ACCEPT_CHARSET: "ISO-8859-2,utf-8;q=0.7,*;q=0.3"

HTTPACCEPTENCODING: "gzip,deflate,sdch"

HTTPACCEPTLANGUAGE: "pl-PL,pl;q=0.8,en-US;q=0.6,en;q=0.4"

HTTPCACHECONTROL: "max-age=0"

REMOTEADDR: "127.0.0.1"

REMOTE
HOST: "localhost"

SERVERNAME: "localhost"

SERVER
PROTOCOL: "HTTP/1.1"

Response

Headers:

None
  • 5
  • Odpowiedz
  • Otrzymuj powiadomienia
    o nowych komentarzach

@sayane: hmm, ale ja nie mam tweetid kolumny, tylko mam w tweet kolumne id :) wiec chyba powinno byc w porzadku tym bardziej ze w tym pierwszym pliku w controlerze wlasnie musialem dodac beforefilter :gettweet i potem :tweetid i dopiero potem ruszylo, tak jakby widzialo, a na stronie takie cos wywala :/
  • Odpowiedz
@sayane: ok juz wiem :) co poszlo nie tak :/ zapomnialem do tabeli dodac tweet_id i dodac zaleznosc :/ do tej drugiej tabeli :) dzieki za pomoc :)
  • Odpowiedz