Mr. Winnymann
2010-Aug-23  19:31 UTC
Unable to upload images using native rails file upload
I am a rails newbie and am trying to build my first app. I have a jobs
and categories controller and models respectively.
CONTROLLER:
def new
    @job = Job.new
    @catergory = Catergory.all
    respond_to do |format|
      format.html # new.html.erb
      format.xml  { render :xml => @job }
    end
  end
#THIS IS A group of 10 RADIO_BUTTONS TO SELECT A CATEGORY FROM. BY
DEFAULT THE FIRST ONE IS SELECTED. !!!!!!!!!!AM STUCK HOW TO WORK
IT!!!!!!!!!!!!maybe a partial???
	<dt><%= f.label "Category" %></dt>
	<% @job.catergory.each do | f | %>
		<dd>
			<%= f.radio_button :name, :id %>
		</dd>
	<% end -%>
# UPLOAD a file for the logo in the controller?????
  def upload
    uploaded_io = params[:job][:logo]
      File.open(Rails.root.join(''public'',
''images'',
uploaded_io.original_filename), ''w'') do |file|
        file.write(uploaded_io.read)
      end
  end
#VIEW FILE views/jobs/new.html.erb
<dl>
<% form_for (@job, :html => {:multipart => true }) do |f| %>
  <%= f.error_messages %>
<dt><%= f.label "title" %></dt>
    	<dd>
		<%= f.text_field :title %>
		<br>
		<span  class="hint">"Senior Ruby Developer" or
"HTML5 CSS3 Guru"</
span>
	</dd>
yada yada yada...
yada yada yada...
yada yada yada...
    <dt><%= f.label "Name" %></dt>
    <dd>
		<%= f.text_field :company %>
		<br>
		<span  class="hint">Example: ''Safarista
Design'', ''Safrista Jobs'' or
''37signals''</span>
	</dd>
</dl>
yada yada yada...
yada yada yada...
yada yada yada...
<%= f.submit ''Step 2: Proceed to preview your ad
→'' %>
<% end %>
This is not working. What am i doing wrong?
-- 
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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.
Mr. Winnymann
2010-Aug-23  19:35 UTC
Re: Unable to upload images using native rails file upload
There was a mistake while pasting
I am a rails newbie and am trying to build my first app. I have a jobs
and categories controller and models respectively.
CONTROLLER:
def new
    @job = Job.new
    @catergory = Catergory.all
    respond_to do |format|
      format.html # new.html.erb
      format.xml  { render :xml => @job }
    end
  end
# UPLOAD a file for the logo in the controller?????
  def upload
    uploaded_io = params[:job][:logo]
      File.open(Rails.root.join(''public'',
''images'',
uploaded_io.original_filename), ''w'') do |file|
        file.write(uploaded_io.read)
      end
  end
#VIEW FILE views/jobs/new.html.erb
<dl>
<% form_for (@job, :html => {:multipart => true }) do |f| %>
  <%= f.error_messages %>
<dt><%= f.label "title" %></dt>
        <dd>
                <%= f.text_field :title %>
                <br>
                <span  class="hint">"Senior Ruby
Developer" or "HTML5
CSS3 Guru"</
span>
        </dd>
#THIS IS A group of 10 RADIO_BUTTONS TO SELECT A CATEGORY FROM. BY
DEFAULT THE FIRST ONE IS SELECTED. !!!!!!!!!!AM STUCK HOW TO WORK
IT!!!!!!!!!!!!maybe a partial???
        <dt><%= f.label "Category" %></dt>
        <% @job.catergory.each do | f | %>
                <dd>
                        <%= f.radio_button :name, :id %>
                </dd>
        <% end -%>
yada yada yada...
yada yada yada...
yada yada yada...
    <dt><%= f.label "Name" %></dt>
    <dd>
                <%= f.text_field :company %>
                <br>
                <span  class="hint">Example: ''Safarista
Design'',
''Safrista Jobs'' or
''37signals''</span>
        </dd>
</dl>
yada yada yada...
yada yada yada...
yada yada yada...
<%= f.submit ''Step 2: Proceed to preview your ad
→'' %>
<% end %>
This is not working. What am i doing wrong?
-- 
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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.
Mr. Winnymann
2010-Aug-24  11:19 UTC
Re: Unable to upload images using native rails file upload
I have 2 models Category and Job. How do I make the user select a category from a list of radio buttons in the view/jobs/new form. How do I then associate the job with the selected Category. Please help. On Aug 23, 8:35 pm, "Mr. Winnymann" <nke...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> There was a mistake while pasting > > I am a rails newbie and am trying to build my first app. I have a jobs > and categories controller and models respectively. > > CONTROLLER: > > def new > @job = Job.new > @catergory = Catergory.all > > respond_to do |format| > format.html # new.html.erb > format.xml { render :xml => @job } > end > end > > # UPLOAD a file for the logo in the controller????? > def upload > uploaded_io = params[:job][:logo] > File.open(Rails.root.join(''public'', ''images'', > uploaded_io.original_filename), ''w'') do |file| > file.write(uploaded_io.read) > end > end > > #VIEW FILE views/jobs/new.html.erb > <dl> > <% form_for (@job, :html => {:multipart => true }) do |f| %> > <%= f.error_messages %> > > <dt><%= f.label "title" %></dt> > <dd> > <%= f.text_field :title %> > <br> > <span class="hint">"Senior Ruby Developer" or "HTML5 > CSS3 Guru"</ > span> > </dd> > > #THIS IS A group of 10 RADIO_BUTTONS TO SELECT A CATEGORY FROM. BY > DEFAULT THE FIRST ONE IS SELECTED. !!!!!!!!!!AM STUCK HOW TO WORK > IT!!!!!!!!!!!!maybe a partial??? > > <dt><%= f.label "Category" %></dt> > <% @job.catergory.each do | f | %> > <dd> > <%= f.radio_button :name, :id %> > </dd> > <% end -%> > > yada yada yada... > > yada yada yada... > > yada yada yada... > > <dt><%= f.label "Name" %></dt> > <dd> > <%= f.text_field :company %> > <br> > <span class="hint">Example: ''Safarista Design'', > ''Safrista Jobs'' or > ''37signals''</span> > > </dd> > </dl> > > yada yada yada... > > yada yada yada... > > yada yada yada... > > <%= f.submit ''Step 2: Proceed to preview your ad →'' %> > > <% end %> > > This is not working. What am i doing wrong?-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
rajeevsharma86
2010-Aug-24  11:57 UTC
Re: Re: Unable to upload images using native rails file upload
http://visionmasterdesigns.com/tutorial-create-blog-using-ruby-on-rails-2-relationship/2/ Do same as with yours Category and job On Tue, Aug 24, 2010 at 4:49 PM, Mr. Winnymann <nkelem-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I have 2 models Category and Job. How do I make the user select a > category from a list of radio buttons in the view/jobs/new form. How > do I then associate the job with the selected Category. Please help. > > On Aug 23, 8:35 pm, "Mr. Winnymann" <nke...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > There was a mistake while pasting > > > > I am a rails newbie and am trying to build my first app. I have a jobs > > and categories controller and models respectively. > > > > CONTROLLER: > > > > def new > > @job = Job.new > > @catergory = Catergory.all > > > > respond_to do |format| > > format.html # new.html.erb > > format.xml { render :xml => @job } > > end > > end > > > > # UPLOAD a file for the logo in the controller????? > > def upload > > uploaded_io = params[:job][:logo] > > File.open(Rails.root.join(''public'', ''images'', > > uploaded_io.original_filename), ''w'') do |file| > > file.write(uploaded_io.read) > > end > > end > > > > #VIEW FILE views/jobs/new.html.erb > > <dl> > > <% form_for (@job, :html => {:multipart => true }) do |f| %> > > <%= f.error_messages %> > > > > <dt><%= f.label "title" %></dt> > > <dd> > > <%= f.text_field :title %> > > <br> > > <span class="hint">"Senior Ruby Developer" or "HTML5 > > CSS3 Guru"</ > > span> > > </dd> > > > > #THIS IS A group of 10 RADIO_BUTTONS TO SELECT A CATEGORY FROM. BY > > DEFAULT THE FIRST ONE IS SELECTED. !!!!!!!!!!AM STUCK HOW TO WORK > > IT!!!!!!!!!!!!maybe a partial??? > > > > <dt><%= f.label "Category" %></dt> > > <% @job.catergory.each do | f | %> > > <dd> > > <%= f.radio_button :name, :id %> > > </dd> > > <% end -%> > > > > yada yada yada... > > > > yada yada yada... > > > > yada yada yada... > > > > <dt><%= f.label "Name" %></dt> > > <dd> > > <%= f.text_field :company %> > > <br> > > <span class="hint">Example: ''Safarista Design'', > > ''Safrista Jobs'' or > > ''37signals''</span> > > > > </dd> > > </dl> > > > > yada yada yada... > > > > yada yada yada... > > > > yada yada yada... > > > > <%= f.submit ''Step 2: Proceed to preview your ad →'' %> > > > > <% end %> > > > > This is not working. What am i doing wrong? > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > . > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- Thanks: Rajeev sharma -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.