[Rails] Re: About haml and ruby on rail

2009-04-18 Thread Marnen Laibow-Koser

Nilesh Kulkarni wrote:
[...]
> 
> thank you for help i have corrected all, 

I'm glad my advice was helpful.

> only one problem is
> 
> Delete
> 
> is converted into =>
> 
> %a.ActionLink{ :href => "#", :onclick => "if(confirm("Are you sure you 
> want to delete this track and associated media file?")) 
> showPane(parseLocation("#{track_path}"),true,false,true,"delete");return 
> false;" } Delete
> 
> only this code is showing error rest all is correct

The error (not a Ruby- or Haml-specific one) should be obvious with 
about 5 seconds of inspection.  If you can't see it, you have no 
business programming in *any* language.  Don't expect other people to do 
your work for you on things this simple!

Best,
--
Marnen Laibow-Koser
http://www.marnen.org
mar...@marnen.org
-- 
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 post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: About haml and ruby on rail

2009-04-18 Thread Nilesh Kulkarni

Marnen Laibow-Koser wrote:
> On Apr 14, 7:55�am, Nilesh Kulkarni 
> wrote:
> 
> You have an elsif without a condition.  Did you mean else?  And why an
> h4 when there's no h3 to nest it in?
> 
> Let me know if you have any further questions.  But if you're going to
> work with Rails, *please* take the time to learn the Rails way of
> doing things -- you will be much happier.
> 


thank you for help i have corrected all, only one problem is

Delete

is converted into =>

%a.ActionLink{ :href => "#", :onclick => "if(confirm("Are you sure you 
want to delete this track and associated media file?")) 
showPane(parseLocation("#{track_path}"),true,false,true,"delete");return 
false;" } Delete

only this code is showing error rest all is correct
-- 
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 post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: About haml and ruby on rail

2009-04-16 Thread Marnen Laibow-Koser

On Apr 14, 7:55 am, Nilesh Kulkarni 
wrote:
> hi all,
>
>    I am converting my view into HAML format i have done it with
> "Html2Haml" command, then I removed all the "- end" from haml code and
> my indentation is also correct,but now  it shows following errors
>  I have kept code of show.html.erb and show.html.haml in attachment.
>
> please help me I am not getting what exactly the error is?
>
> compile error D:/aflatune/app/views/tracks/show.html.haml:33: syntax
> error, unexpected tCONSTANT
[...]

OK, after some investigation, it looks like you have an unmatched
brace on line 32, which is exactly the sort of thing I suspected.

By the way, your view file contains some of the worst view code I've
ever seen -- it contains *way* too much logic, and much of that logic
is poorly written.  Some suggestions for fixing it up:

> - if @content_type == :mp3

You probably don't need this.  If I understand correctly what you're
doing, you should probably use respond_to in the controller to set up
different views.

> %script

Don't do that.  Learn about Haml filters and use :javascript instead.
Better yet, get rid of the inline JavaScript -- put it in a separate
file.

> - @ShareContentTitle = "#...@track.title} from album #...@album.title} at 
> aflatune!"

This should be a method on the Track model.

> - trackIndex = 0;
> - for track in @album.tracks
> - suffix = "track...@track.to_param}_album_#{@album.id}_track_#{trackIndex}";
> %li.SongListItem
>   = track_link_html(suffix ,track.to_param, track.title)
> - trackIndex = trackIndex + 1

This is not properly indented, so it will not work (the entire body of
the for loop should be indented).  But even if it *were* properly
indented, it would be a bad way of doing things.  Ruby is not PHP --
don't write it as if it were.  In particular, in Ruby, it should
*never* be necessary to manually increment a loop index as you're
doing here trackIndex.  What you want is something like this:

- @album.tracks.each_with_index do |track, i|
  %li.SongListItem= track_link_html("track...@track.to_param}_album_#
{...@album.id}_track_#{i}" ,track.to_param, track.title)

(yes, that's two lines instead of six!)

Also note that in Ruby, it is considered poor style to use CamelCase
variable names such as trackIndex.  The usual way of writing this
would be track_index.  You also don't need the semicolons at the end
of a line, and most people don't use them.  Please take the time to
study some good Ruby style.

> - @phrase = nil;
> - @video_id = @track[:bare_id]
> - @videoSearchHeadingTag = 'h3';
> - @videoSearchHeading = 'Related videos';
> - @showLongVideoResults = true
> = render :partial => 'home/video_search'

Setting this many variables in the view is a sure sign that something
is wrong.  These should either be model methods or set in the
controller.

Alternatively, if you're passing these values into the partial, please
read up on proper render :partial syntax, in particular the use
of :locals.  You probably want something like
render :partial => 'partial', :locals => {:video_id =>
@track.bare_id, :another_variable => 'another value', :next_variable
=> 'and so on'...}

> - elsif
> %h4
>   Sorry, the track could not be located in our system.

You have an elsif without a condition.  Did you mean else?  And why an
h4 when there's no h3 to nest it in?

Let me know if you have any further questions.  But if you're going to
work with Rails, *please* take the time to learn the Rails way of
doing things -- you will be much happier.

Best,
--
Marnen Laibow-Koser
mar...@marnen.org
http://www.marnen.org
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: About haml and ruby on rail

2009-04-15 Thread Marnen Laibow-Koser

Nilesh Kulkarni wrote:
[...]
> 
> code of show.html.erb and show.html.haml is in "haml_and_html_file.txt"
> attachment whth first post..

Sorry, I missed that.  I'll check it out.

Best,
--
Marnen Laibow-Koser
http://www.marnen.org
mar...@marnen.org
-- 
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 post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: About haml and ruby on rail

2009-04-14 Thread Nilesh Kulkarni

Marnen Laibow-Koser wrote:
> Nilesh Kulkarni wrote:
> 
> So you probably have a missing parenthesis or something like that.  But 
> we can't tell for sure without seeing the Haml file.
> 
> Best,
> --
> Marnen Laibow-Koser
> http://www.marnen.org
> mar...@marnen.org

code of show.html.erb and show.html.haml is in "haml_and_html_file.txt"
attachment whth first post..
-- 
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 post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: About haml and ruby on rail

2009-04-14 Thread Marnen Laibow-Koser

Nilesh Kulkarni wrote:
[...]
> 
> please help me I am not getting what exactly the error is?
> 
> compile error D:/aflatune/app/views/tracks/show.html.haml:33: 

That's the approximate location of the error.  What is in that file 
around line 33?

> syntax
> error, unexpected tCONSTANT, expecting ')'
[...]

So you probably have a missing parenthesis or something like that.  But 
we can't tell for sure without seeing the Haml file.

Best,
--
Marnen Laibow-Koser
http://www.marnen.org
mar...@marnen.org
-- 
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 post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---