Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- Django
- jquery
- Python
- 홈페이지 개발하기
- rails review
- 루비
- 루비 온 레일즈
- 레일즈
- 웹 프로그래밍 입문
- 꿀팁
- 모듈화
- 데스크탑애플리케이션
- 웹 프론트엔드
- django 공부하기
- 모닝버드
- 루비온레일즈
- express-mysql-session
- 웹 프로그래밍
- nodejs api
- 예스인테리어
- 프론트엔드
- nodejs
- node.js
- 웹프로그래밍
- 장고
- 장고 공부하기
- 파이썬 웹 프레임워크
- rails
- Ruby On Rails
- css3
Archives
- Today
- Total
노래하듯 이야기하고, 춤추듯 정복하라.
[Ruby & Rails] Post모델에 별점(Review) 기능 추가하기2 본문
★ 파일과 image 추가
- jquery.raty.js 파일과 image 3가지 추가 (star-half.png / star-off.png / star-on.png )
-> mackenzie git 레파지토리 주소 => https://github.com/mackenziechild/movie_review
★ posts/show.html.erb 코드변경 및 추가
* 변경
<%= review.rating %>
↓↓↓
<div class="star-rating" data-score=<%= reivew.rating %>></div>
* js 코드추가
<script>
$('.star-rating').raty({
path: '/assets/',
readOnly: true,
return $(this).attr('data-score');
}
});
</script>
★ comments/_form.html.erb 코드변경 및 추가
* 변경
<%= f.label :rating %>
<%= f.number_field :rating %>
↓↓↓
<div id="star-rating"></div>
* js 코드추가
<script>
$('#star-rating').raty({
path: '/assets',
scoreName: 'comment[rating]'
});
</script>
'프로그래밍 > Ruby & Rails' 카테고리의 다른 글
[Ruby & Rails] Faker젬을 사용해 더미데이터 입력하기 (0) | 2018.08.17 |
---|---|
[Ruby & Rails] 관리자 권한 부여하기, 사용한 Gem: Cancancan + Rolify (1) | 2018.08.15 |
[Ruby on Rails] Post모델에 별점(Review) 기능 추가하기 (0) | 2018.08.10 |
[Ruby on Rails] Post모델에 댓글(comments) 기능 추가하기 (0) | 2018.08.10 |
[Ruby on Rails] 좋아용 기능 구현하기: acts_as_votable (2) | 2018.08.09 |
Comments