I want to render a different link_to name and url path based on an objects "status" attribute in the index view. Would love to know how to get the logic out of the view, but barring that, when I use if/else statements in erb I can only render 4 different link options. Likewise, case/when is only allowing me to show 2 different results? Not sure what I am doing wrong (except I am sure I am putting way too much logic in the view). Any help or guidelines would be much appreciated.
one way: link_to(obj.status_name, #{obj.status}_path) this would require any extra routes to be added, as well as a status_name attribute/model to supply the text. On Aug 5, 2:31 pm, Brad <brad.we...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I want to render a different link_to name and url path based on an > objects "status" attribute in the index view. Would love to know how > to get the logic out of the view, but barring that, when I use if/else > statements in erb I can only render 4 different link options. > Likewise, case/when is only allowing me to show 2 different results? > Not sure what I am doing wrong (except I am sure I am putting way too > much logic in the view). > > Any help or guidelines would be much appreciated.
Eric, THANK YOU! That will work. I will have to modify some routes, but this is so much cleaner than what I was trying to do. Thanks alot for a second set of eyes. Brad On Aug 5, 4:31 pm, Eric <ericgh...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> one way: > > link_to(obj.status_name, #{obj.status}_path) > > this would require any extra routes to be added, as well as a > status_name attribute/model to supply the text. > > On Aug 5, 2:31 pm, Brad <brad.we...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > I want to render a different link_to name and url path based on an > > objects "status" attribute in the index view. Would love to know how > > to get the logic out of the view, but barring that, when I use if/else > > statements in erb I can only render 4 different link options. > > Likewise, case/when is only allowing me to show 2 different results? > > Not sure what I am doing wrong (except I am sure I am putting way too > > much logic in the view). > > > Any help or guidelines would be much appreciated.