업로드 된 이미지에 페이지의 URL을 삽입하려고합니다.
아래 코드는 이미 가지고 있지만 작동하지 않습니다.모델 내에서 변수를 사용하려면 어떻게해야합니까?
내 모델에 어떤 문제가 있습니까? 이 문제를 어떻게 해결할 수 있습니까?
내 협회
- 는 사용자 has_one :
- 프로필 belongs_to 프로필 : 저장하기 전에 사용자
모델/user.rb
before_save :text_to_insert?
def text_to_insert
nickname = self.profile.nickname
end
has_attached_file :user_avatar,
:styles => {
:thumb=> "100x100>",
:small => "400x400>" },
:convert_options => {
:small => '-fill white -undercolor "#00000080" -gravity South -annotate +0+5 " example.com/'+ nickname +' "' }
있는지 확인하십시오
:text_to_insert
즉후
?
을 제거하려고 보인다. http://stackoverflow.com/questions/11058271/print-out-the-zombies-name-and-graveyard-rails-for-zombies/11058367#11058367 – DaMainBoss을 참조하십시오. 현재 페이지의 URL, 이것 좀 봐 http://stackoverflow.com/questions/2165665/how-do-i-get-the-current-url-in-ruby-on-rails – DaMainBoss
액세스 방법을 알고 있습니다. 컨트롤러 또는보기 있지만 모델에서 열을 :( – Foo