Recent Posts
Pages: 1 2 3 4 5 6 7 8 9 10 11 ... 23
|
Jul 20, 2008
|
Topic: General Ruby/Rails Discussion / RJS partials - or - DRY RJS Hi Andy, (and other softies) I got this helper approach to work, but the problem is that my RJS needs a lot of the controller’s instance variables, and the helper doesn’t have access to this context. I’m using YM4R to work with google maps, and I have an rjs that basically clears the maps and displays a few default markers retrieved from a database. I have other rjs files that do more complicated rendering, but before that they all need the same “reset” rjs code. What do you recommend? Thanks, Ismail |
|
Jul 18, 2008
|
Topic: General Ruby/Rails Discussion / RoR image_tag session variable I have a slidehsow on the website. i have to change one of the banners. the code in view looks like this: <%= link_to( image_tag(session:slide_array], :size => “580×146”), session:slide_link] ) %> can someone explain where do “slide_array” and “slide_link” get set? how can i change them. i even used netbeans and other tools to figure out their roots but no luck. help please thanks you |
|
Jul 16, 2008
|
Topic: General Ruby/Rails Discussion / Populate collection_select with Ajax I am trying to populate a collection_select based off a value selected from a different collection_select (drop down) Any good examples anywhere. I have used the observe_field element in the past, but only to change a value inside a div, never to populate an element. Thanks, Ron |
|
Jul 15, 2008
|
Topic: General Ruby/Rails Discussion / How to use Skype to make PSP as PSP phone Could someone tell me how to put Skype on pocket pc such as on psp? I am very urgent need of this information!! |
|
Jul 12, 2008
|
Topic: General Ruby/Rails Discussion / Planning stage - database structure questions Yeah, I think you have to do a brute-force copy of the plan and all of its tasks, something like: actual_plan = Plan.create(plan.attributes) # now copy all the tasks plan.tasks.each do |task| actual_plan.tasks.create(task.attributes) end That’s off the top of my head, syntax might be off a bit. Probably best to wrap this inside of a method on Plan:
def create_actual_plan
actual = Plan.new(self.attributes)
actual.template = false
actual.save
actual.tasks.each { |task| self.tasks.create(task.attributes) }
actual # return the new plan
end
So now your controller just do this: new_plan = plan.create_actual_plan redirect_to new_plan # assuming Rails 2.0.2 and higher Again I’m just making this up off the top of my head, but I think it’s in the ballpark…? |
|
Jul 12, 2008
|
Topic: General Ruby/Rails Discussion / How to Save Youtube to iPhone As an eligible iPhone users, add DVD movies to iPhone and save youtube to iPhone is the basic skill. Now, it’s said, iPhone 3G will launch on July 11th, [url=http://www.daniusoft.com/tutorial/iphone2.0.html]new features about the new iPhone 3G[/url] here, it’s really a good news to iPhone fans you and me. Following are three ways to save Youtube to iPhone I often used:
1.Copy and paste the link of video from Youtube in this website: http://www.videodownloadx.com. Then click download and right click on ‘the download then save as.’, while saving, you can type the video as “title.flv”. 2.iPhone can play MP4 video, MP3, m4a audio. After downloading, you should convert the *.flv to *.mp4 format. So you can download third party software to convert Youtube to iPhone (video to iPhone 3G). If you already know how to convert Youtube to iPhone (video to iPhone 3G), you can go to Part two; else, as convert Youtube to iPhone I prefer using Daniusoft Video to iPhone Converter, it converts video formats to iPhone including AVI, MP4, MPEG, WMV, XviD, H.264, DAT, MOV, ASF and FLV, etc. to iPhone MPEG-4, H.264, and rip video audio to iPhone MP3, M4A, AAC. It can also convert Youtube video to iPhone 3G, too. You can free download [url=http://www.daniusoft.com/video-to-iphone.html]Daniusoft Video to iPhone Converter[/url] here and convert Youtube to iPhone with its guide.
1. Step 1 and step two as above. 2. After save Youtube to iPhone, Mac users can use iSquint. iSquint is an iPod video conversion app for Mac OS X that can be use to convert Youtube to iPhone too. It’s a free application with similar export features as Daniusoft Video to iPhone Converter. iSquint is awesome! It can be downloaded at http://www.macupdate.com/info.php/id/19769/isquint.
Addition: You can burn the downloaded Youtube video to DVD with DVD Burn software. MxTube is a YouTube video downloader that allows you to save YouTube videos directly to your iPhone. You can download it here – [url=http://www.installerapps.com/2008/03/13/mxtube/]Installer app[/url].
When you open the app you will see a lower menu bar with four options; Featured, Search, Videos and Downloads. The Search option allows you to search YouTube for videos. YouTube actually has two versions of every video, high and low quality, once you have found a video you would like to download, you can select either high, low, or both. The videos will download in sequence and in the background. Once it’s done downloading, the video is available from within the application.
The Youtube video to iPhone can help you more: http://youtube.com/watch?v=m-6BceaGT6A. The third way to save [b]Youtube to iPhone/b needs Mxtube, it’s free but you won’t be able to sync the videos back to your computer. If you don’t care to store video back to your computer, then it’s also a good way for you.
|
|
Jul 11, 2008
|
Topic: General Ruby/Rails Discussion / Planning stage - database structure questions Jeff, I think that is a good solution. less DB cruft. I am familiar with named scopes, although I have not used them before. What do you think the best way is to turn a template into an actual, as many users will likely be using the same template? I am thinking
My brain is having a hard time visualizing this part. Thanks for you help. |
|
Jul 11, 2008
|
Topic: General Ruby/Rails Discussion / Planning stage - database structure questions I think the “template plan” will need more than one table, actually. It sounds like you’d need a Then you’d need two tables for the “actuals”: But since those tables are practically identical, it feels redundant. What about something like this? Table: Table: In other words, a Plan has many Tasks. Both plans and tasks can be marked as “templates” or not (actuals). That way you can also quickly turn an actual into a new template by copying it and turning on the template flag. If you’re using Rails 2.1, you can use named scopes to quickly query for template plans and their tasks – just let me know if you need an example for that. Not sure if this helps…? |
|
Jul 11, 2008
|
Topic: General Ruby/Rails Discussion / How to use Skype to make PSP as PSP phone Ow great, i hope this one will have FM radio, Apple has been a b*tch against FM radio. |
|
Jul 10, 2008
|
Topic: General Ruby/Rails Discussion / Planning stage - database structure questions Hi, I am in the planning stage of an application where users can define a set of tasks by week, and can share these with other users. Once their plan is active they can edit each task and define what was actually completed. I am imagining a table for “plans” and table “actuals” or something like that. So when a user selects an existing plan or creates a new plan – it could then be copied(selected and inserted) to the actuals table. Each user would also have unique starting and end dates based on their start date. The plan would be a template that could be shared among users. And actuals would be a unique copy including what a user actually did. I have two questions1st – Does that make any sense? Is their a better way to accomplish this through a database relationship? 2nd – How would I copy all these records from on table to the other? I’d love to hear your thoughts. Thanks |
|
Jul 9, 2008
|
Topic: General Ruby/Rails Discussion / How to verify email id using rails See my answer at http://forum.softiesonrails.com/forums/1/topics/160?page=1#posts-570 |
|
Jul 9, 2008
|
Topic: Rails on Windows / How to conform email address from action mailer in rails Try the email veracity plugin It’s supposed to do a DNS lookup for MX records to make sure it’s a real address. |
|
Jul 9, 2008
|
Topic: General Ruby/Rails Discussion / How to verify email id using rails Using action mailer it possible to verify email id? |
|
Jul 9, 2008
|
Topic: Rails on Windows / How to conform email address from action mailer in rails Hi, It is possible to conform email address from rails. e.g sunny@abc.com is a fake email id so when I am sending email to this and mails get failed i want to know? I want to do this at rails side on on postfix? |
|
Jul 7, 2008
|
Topic: General Ruby/Rails Discussion / Symmetrical Routes for Nested Resources Great! |
|
Jul 7, 2008
|
Topic: General Ruby/Rails Discussion / Symmetrical Routes for Nested Resources Wow. I can’t imagine a better response to a software development question. It’s precisely what I needed, and it worked like a charm. Thanks! |
|
Jul 7, 2008
|
Topic: General Ruby/Rails Discussion / Symmetrical Routes for Nested Resources Hey Mike, Be forewarned I haven’t tried any of the following to check my syntax, and I’m assuming you’re on Rails 2.0 or higher…. I assume you’ve already done something like this to get the “normal” routes working: map.resources :books map.resources :owners But it may not be obvious that you can do this: map.resources :books, :has_many => :owners map.resources :owners, :has_many => :books This means that the OwnersController’s So a common approach is to use a before_filter to find out which scenario we’re in. Also, it sounds like once you find the owners, you need to transform those to the ownerships: class OwnersController < ApplicationController before_filter :find_book def index # If we're being used as an "inner" resource, then # only get the owners for the given book @owners = @book.owners if @book # Otherwise, we should get all books @owners ||= Owner.find(:all) # Or you can do Owner.all in Rails 2.1 or above) respond_to do |format| format.html # render html template format.xml # render xml template end end def find_book # Find the "outer" resource if necessary @book = Book.find(params[:book_id]) if params[:book_id] end In your XML template, you can loop through all the ownerships, and whenever you need the number of copies, use the ownership data:
xml.book_data do
@owners.each do |owner|
xml.title owner.ownership.book.title
xml.copies owner.ownership.copies
end
end
Does this help at all? |
|
Jul 6, 2008
|
Topic: General Ruby/Rails Discussion / Symmetrical Routes for Nested Resources I’m having trouble setting up nested resources in a particular way that makes sense to me. Given rules like these:
I have a many-to-many relationship of Owners-to-Books with the “link” table (we’ll call it “Ownerships” since I can’t think of a nice name) having an attribute for tracking the number of copies of a book an owner owns. I have no problem listing all books, or listing all owners: What I can’t figure out is how to set up my routes/controllers to list all books owned by a particular owner, and all owners that own a particular book (i.e. what I call “symmetrical routes for nested resources”). I’d like the URLs to look something like this:
What’s extra tricky is that I want the listings to also contain the number of copies from the “link” table. So, for example, http://127.0.0.1:3000/owners/7/books.xml might return the equivalent of this as XML: To Kill A MockingBird, 2 The Zombie Survival Guide, 1 War and Peace, 4 Please help this noob :-) Thanks, Mike |
|
Jul 1, 2008
|
Topic: General Ruby/Rails Discussion / RESTful resouces & many-many 2: more complicated Awesome! Way to persevere through it! I hope it works out. |
|
Jul 1, 2008
|
Topic: General Ruby/Rails Discussion / RESTful resouces & many-many 2: more complicated UPDATE: I did what I said last, which was to make approvers and projects nested resources on companies. It works and I’m quite happy with it. It simplified a couple things. I also changed from has_many+through to HABTM. Its RESTful and I think the user interaction will make more sense too. Thanks Jeff. |
|
Jun 30, 2008
|
Topic: General Ruby/Rails Discussion / RESTful resouces & many-many 2: more complicated hmm… I could probably change to create the project from the company. I hadn’t thought of it in that way. It would simplify my problem.. and possibly also simplify the UI. I could do the same thing for Approvers also since they too belong to a company. Those would then make sense as nested resource on Companies, which is not a bad idea..
I’m not exactly sure about the implementation after that but the resource and url of that makes sense to me. I’m gonna guess I need to use that before_filter approach you mentioned above. |
|
Jun 30, 2008
|
Topic: General Ruby/Rails Discussion / RESTful resouces & many-many 2: more complicated Any chance you can change the user interaction at all? I would have guessed that you’d start from a Company page, then create New Project or something. So right from the get go, you know what company is involved, and that makes creating the drop-down lists much easier. In any event, let me know how it all turns out! As long as you can somehow thing of (most) everything in terms of crudding a resource, I think things will still work out. |
|
Jun 30, 2008
|
Topic: General Ruby/Rails Discussion / RESTful resouces & many-many 2: more complicated Close enough… I’ll try to use it as a nested resource. /projects/5/approvers is valid ..sort of.. When editing/creating a project, the user picks the company it belongs to. The app then updates/populates the available choices for approvers that belong to the selected company. Lastly, the user can pick which approvers have authority on that project. I’m probably just bad at explaining this. I think I can bend the nested resource approach to fit my needs. Thanks. |
|
Jun 30, 2008
|
Topic: General Ruby/Rails Discussion / RESTful resouces & many-many 2: more complicated I’m sure I’m not grasping all the details of your situation, but it seems like you have a nested resource here. Something like @projects/5/approvers should return a list of approvers for project #5. Two keys here: one is to setup your routes.rb like this (I’m assuming you’re on Rails 2.x):
and then in your ApproversController, a before_filter :find_project def index # Show list of approvers for the current project @approvers = @project.approvers end private def find_project @project = Project.find(params[:project_id]) end This might not be exactly right, but hopefully this points to a more helpful direction? |
|
Jun 30, 2008
|
Topic: General Ruby/Rails Discussion / RESTful resouces & many-many 2: more complicated I decided to try a custom route as in this railscast: http://railscasts.com/episodes/35 Only I’m getting an error trying to use the named path because it is confused between that and the Show request; both are GETS. Anyway, I’m thinking the custom routes stuff has changed since this railscast. |