# Setting up Fleximage

**URL:** <https://www.ruby-forum.com/t/setting-up-fleximage/148897>\
**Category:** Rails\
**Created:** [September 18, 2008, 4:30am UTC](https://www.ruby-forum.com/t/setting-up-fleximage/148897 "2008-09-18T04:30:51Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rsanheim](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/47e85d/32.png) [@rsanheim](https://www.ruby-forum.com/u/rsanheim)\
**Post date:** [September 18, 2008, 4:30am UTC](https://www.ruby-forum.com/t/setting-up-fleximage/148897/1 "2008-09-18T04:30:51Z")

</div>

Hello!

I’ve been trying today to setup fleximage to handle photo uploads to a  
RoR application by following the tutorial that is provided  
([GitHub: Let’s build from here · GitHub](http://github.com/Squeegy/fleximage/wikis/gettingstarted))

Originally, I just dropped in all of the sample code that they provided,  
which I copied below this question.

- When I tried to access “new” to upload a new photo, I received an  
error of “Called id for nil, which would mistakenly be 4 – if you  
really wanted the id of nil, use object\_id”, which I understood to be  
caused by the fact that I was using @photo without initializing it in  
the controller.

- I added @photo = Photo.new to the controller for “new” but then it  
returned that it could not find the table Photo.

- I created a new migration for a photo table, including only the fields  
for name and author, which are also requested in the provided “new”  
view.

- Now, it just returns the error “undefined method `photos\_path’ for  
#ActionView::Base:0x230ee70”

Since I’m incredibly new to fleximage, I’m not exactly sure if I’m going  
in the wrong direction with my troubleshooting, if a table even needed  
to be created for the photos or what my next step should be.

If anyone could point me in the right direction, I’d appreciate it. 🙂

Model (photo.rb)  
class Photo \< ActiveRecord::Base  
acts\_as\_fleximage :image\_directory =\> ‘public/images/uploaded\_photos’  
end

Controller (photos\_controller.rb)  
class PhotosController \< ApplicationController

def new

end

def create  
@photo = Photo.new(params[:photo])  
if @photo.save  
redirect\_to photo\_url(@photo)  
else  
flash[:notice] = ‘Your photo did not pass validation!’  
render :action =\> ‘new’  
end  
end

end

View (new.html.erb)  
\<% form\_for @photo, :html =\> { :multipart =\> true } do |f| %\>

**Name**  
 \<%= f.text\_field :name %\>

**Author**  
 \<%= f.text\_field :author %\>

**Upload Image**  
 \<%= f.file\_field :image\_file %\>  
 or URL: \<%= f.text\_field :image\_file\_url %\>

\<%= f.submit "Create" %\>

\<% end %\>

---

<div class="post-metadata">

**Author:** ![rsanheim](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/47e85d/32.png) [@rsanheim](https://www.ruby-forum.com/u/rsanheim)\
**Post date:** [September 18, 2008, 9:01am UTC](https://www.ruby-forum.com/t/setting-up-fleximage/148897/2 "2008-09-18T09:01:59Z")

</div>

Hi!  
I am sorry to hear your difficulties with the tutorial. I am a  
beginner in  
this group so I this you need to pose your question to someone who  
really  
knows what about ROR.  
Good luck!

On Thu, Sep 18, 2008 at 11:30 AM, Rob Scott \<

---

<div class="post-metadata">

**Author:** ![rsanheim](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/47e85d/32.png) [@rsanheim](https://www.ruby-forum.com/u/rsanheim)\
**Post date:** [October 17, 2008, 1:15pm UTC](https://www.ruby-forum.com/t/setting-up-fleximage/148897/3 "2008-10-17T13:15:40Z")

</div>

Hi,

In your view (new.html.erb) file

This line \<% form\_for @photo, :html =\> { :multipart =\> true } do |f|  
%\> should be like below

\<% form\_for @photo, :url=\>{:action=\>‘ACTIONNAME’, }, :html =\>  
{ :multipart =\> true } do |f| %\>

i.e give more argument :url=\>{} to form\_for

To overcome “undefined method `photos\_path’ for #\<ActionView::Base:  
0x230ee70\>”
