On 4 July 2015 at 03:40, Federicko fedom...@gmail.com wrote:
Hi Colin,
I have done that but slightly differently as the 'this' variable was giving
me an error.
Sorry it should have been 'self' not 'this' of course, as I am sure
you worked out. ruby != c++
Controller didn't change. It
Hi Colin,
I have done that but slightly differently as the 'this' variable was giving
me an error.
Controller didn't change. It still just calls the rankup or rankdown
methods in the model.
Here's the code for that:
def rank
@this_article = Article.find(params[:id])
if (params[:rank] ==
Thanks for the detailed post.
I will definitely check out the gem
--
You received this message because you are subscribed to the Google Groups Ruby
on Rails: Talk group.
To unsubscribe from this group and stop receiving emails from it, send an email
to
On 2 July 2015 at 11:07, Federicko fedom...@gmail.com wrote:
OK, so I have modified the code following Colin's suggestion.
Check it out:
In the controller, my action is as follows:
def rank
@this_article = Article.find(params[:id])
if (params[:rank] == 'up')
OK, so I have modified the code following Colin's suggestion.
Check it out:
In the controller, my action is as follows:
def rank
@this_article = Article.find(params[:id])
if (params[:rank] == 'up')
@this_article.rankup(params[:rank])
else
@this_article.rankdown(params[:rank])
Oh yeah, like this?
In controller:
def rank
@this_article = Article.find(params[:id])
if (params[:rank] == 'up')
@this_article.rankup
else
@this_article.rankdown
end
redirect_to articles_path()
end
In the model:
def rankup()
@affected_article = Article.find_by(ranking:
On 2 July 2015 at 12:04, Federicko fedom...@gmail.com wrote:
Oh yeah, like this?
In controller:
def rank
@this_article = Article.find(params[:id])
if (params[:rank] == 'up')
@this_article.rankup
else
@this_article.rankdown
end
redirect_to articles_path()
end
In
CORRECTION:
Had a little fun with acts_as_list...
.
--
You received this message because you are subscribed to the Google Groups Ruby
on Rails: Talk group.
To unsubscribe from this group and stop receiving emails from it, send an email
to rubyonrails-talk+unsubscr...@googlegroups.com.
To
Had a little fun with acts_like_list... Build in Rails 3, should work in
Rails 4 though???
Add to your gem file:
gem 'acts_as_list'
Run:
bundle install
Add the field position as an integer to your Articles table:
From rails console:
RUN: rails g migration AddPositionToArticle
Yeah, I will check that gem out.
I basically wanted to do this to learn the ways of the Rails :p
--
You received this message because you are subscribed to the Google Groups Ruby
on Rails: Talk group.
To unsubscribe from this group and stop receiving emails from it, send an email
to
On 1 July 2015 at 09:33, Federicko fedom...@gmail.com wrote:
Yeah, I will check that gem out.
I basically wanted to do this to learn the ways of the Rails :p
In that case I would have two member methods rankup and rankdown that
do everything, including saving, all wrapped in a transaction.
So
On Tuesday, June 30, 2015 at 4:46:40 PM UTC+1, Federicko wrote:
Yes but I also call those method from the Class method rank and it needs
to save.
This is always my dilemma, just exactly what or how much code should go
into controller and model?
Like in my example, before when I had
On 1 July 2015 at 05:06, Federicko fedom...@gmail.com wrote:
Hi All,
First of all, let me quickly clarify the meaning of ranking here.
All I'm doing is move an article up or down in the display on the index
file.
Quick example. Below is a sample of the Articles table:
ID title
Hi All,
First of all, let me quickly clarify the meaning of ranking here.
All I'm doing is move an article up or down in the display on the index
file.
Quick example. Below is a sample of the Articles table:
ID titleranking
5 Rails is cool
Yes but I also call those method from the Class method rank and it needs to
save.
This is always my dilemma, just exactly what or how much code should go
into controller and model?
Like in my example, before when I had everything in the controller, people
suggested that I put that code in the
Maybe take out the save from rankup and rankdown and save in the
controller?
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups Ruby
on Rails: Talk group.
To unsubscribe from this group and stop receiving emails from it,
Hi All,
Thank for the feedback.
Yeah, my next step is to consolidate the two actions together.
Good point on using POST instead of GET.
I will change the link_to helper.
As to using generators, I followed the tutorial and used generators for
creating the model and controllers for Articles and
Jeez For a first time effort, you have done an excellent job... Seems
that you have great instincts..
I don't see your form here, but defs rankup an rankdown should be
consolidated into a controller action 'update'. What's the name of your
view? Seems here it should be called list.
If I
On 28 June 2015 at 22:15, Elizabeth McGurty emcgur...@gmail.com wrote:
Jeez For a first time effort, you have done an excellent job... Seems
that you have great instincts..
I don't see your form here, but defs rankup an rankdown should be
consolidated into a controller action 'update'.
19 matches
Mail list logo